2

サーバー上のファイルにデータを書き込みたい。したがって、次のコードを使用します。

            System.Net.WebClient webClient = new System.Net.WebClient();
            string webAddress = "https://sd2dav.1und1.de/"; //1&1 Webdav
            string destinationFilePath = webAddress + "testfile.txt";
            webClient.Credentials = new System.Net.NetworkCredential("myuser", "mypassword");
            Stream stream = webClient.OpenWrite(destinationFilePath,"PUT");

            UnicodeEncoding uniEncoding = new UnicodeEncoding();

            using(StreamWriter sw = new StreamWriter(stream, uniEncoding))
            {
                sw.Write("text");
                sw.Flush();
            }

            webClient.Dispose();

これは、Visual Studio 2008、.net 3.5 でコンパイルし、Windows 7 で実行すると正常に動作します。ただし、これを Mono for Android (4.4.54) で実行したいと考えています。ここで、コードは実行されますが、何も起こりません。ファイルはサーバー上に作成されません。

これは Mono for Android のバグですか、それとも上記のコードに何か問題がありますか? これを機能させる方法を知っていますか?

更新:この問題に関してhttps://bugzilla.xamarin.com/show_bug.cgi?id=10163でバグを報告しました。うまくいけば、Xamarin の担当者がこれを処理してくれるでしょう。さらに、データをサーバーに送信する別の方法をhttps://stackoverflow.com/questions/14786214/alternative-to-webclient-openwriteで提示しました。

4

0 に答える 0