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