读书人

WebClient 文件下传有关问题的 403

发布时间: 2012-08-16 12:02:15 作者: rapoo

WebClient 文件上传问题的, 403 禁止

WebClient oWebClient = new WebClient();
oWebClient.Credentials = CredentialCache.DefaultCredentials;
oWebClient.DownloadFile(http://192.28.22.66/SITEMP/dddddddd.bmp, @"c:\ddd.bmp");

FileStream fs = new FileStream(@"c:\ddd.bmp";, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
byte[] postArray = r.ReadBytes((int)fs.Length);
Stream postStream = oWebClient.OpenWrite(http://192.28.22.66/SITEMP/mmmm.bmp, "PUT");
string strMessage;
if (postStream.CanWrite)
{
postStream.Write(postArray, 0, postArray.Length);
strMessage = strHontiFileName + "成功!";
}
else
{
strMessage = "失败!";
}

fs.Close();
r.Close();
postStream.Flush();
postStream.Close();
为什么我DownloadFile就没有问题。本地上也能保存,但是我在上传的时候,前面的执行操作都没有问题,但是执行到postStream.Close();
就报错。:"远程服务器返回错误: (403) 已禁止。"
是什么原因,有么有遇到过。


[解决办法]
远程目录能写么?
[解决办法]
IIS目录中设置

读书人网 >C#

热点推荐