0
我想使用我的Windows應用程序將多個圖像文件上傳到網絡服務器。這裏是我的代碼將Windows應用程序中的文件上傳到網絡服務器
public void UploadMyFile(string URL, string localFilePath)
{
HttpWebRequest req=(HttpWebRequest)WebRequest.Create(URL);
req.Method = "PUT";
req.AllowWriteStreamBuffering = true;
// Retrieve request stream and wrap in StreamWriter
Stream reqStream = req.GetRequestStream();
StreamWriter wrtr = new StreamWriter(reqStream);
// Open the local file
StreamReader rdr = new StreamReader(localFilePath);
// loop through the local file reading each line
// and writing to the request stream buffer
string inLine = rdr.ReadLine();
while (inLine != null)
{
wrtr.WriteLine(inLine);
inLine = rdr.ReadLine();
}
rdr.Close();
wrtr.Close();
req.GetResponse();
}
我提到以下鏈接 http://msdn.microsoft.com/en-us/library/aa446517.aspx
我得到異常 遠程服務器返回了意外的響應:(405)不允許的方法。
什麼樣的Web服務器端運行的應用程序? – 2013-03-06 10:19:22
這是在服務器上運行的ASP.Net MVC應用程序我想在不中斷Web應用程序的情況下上傳文件 – NightKnight 2013-03-06 10:33:21
您是否曾設法將* single *文件上傳到服務器?是什麼讓你認爲問題是客戶而不是服務器? – Blachshma 2013-03-06 11:04:05