我有一個桌面應用程序在我的桌面上運行。 我需要將文件路徑發送到在服務器上運行的CGI腳本。 CGI腳本獲取文件路徑並從我的機器上傳內容。幫助需要在Windows Mobile上傳文件
我試圖通過httppost方法發送文件路徑;它不工作 - 任何一個可以建議我怎麼做..方法我都試過有:
WebClient upload = new WebClient();
NetworkCredential nc = new NetworkCredential("test", "admin");
Uri URL = new Uri("http:\\10.10.21.55\\cgi-bin\\file_upload.cgi");
upload.Credentials = nc;
byte [] data = upload.UploadFile(filepath, "c:/Data.txt");
Console.WriteLine(data.ToString());
,我嘗試另一種方式是:
byte[] buf = new byte[8192];
// prepare the web page we will be asking for
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("http://10.10.21.55/cgi-bin/file_upload.cgi");
WebResponse rsp = null;
request.Method = "POST";
request.ContentType = "text/xml";
StreamWriter writer = new StreamWriter(request.GetRequestStream());
writer.WriteLine("hi hiw are you");
writer.Close();
兩種方式都不能正常工作。
但低於回答的代碼在桌面上的WinMo它告訴WebClient的不implimented ...... 請告訴如何在移動
定義「不工作」;怎麼了? *究竟*。你有沒有試過網絡追蹤? – 2009-11-13 07:11:08
請注意,在第二個例子中,你還沒有真正上傳任何東西......第一個例子看起來很有前途(不知道你爲什麼寫了這樣的路徑 - 他們看起來很奇怪)。在您澄清症狀之前,我們無法診斷。 – 2009-11-13 07:12:58
你還需要澄清一下cgi期待的是什麼?它是否期待請求正文中的單個文件?還是期待多部分表單編碼? – 2009-11-13 07:13:55