首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

WebClient 文件下传有关问题的, 403 禁止

2012-08-16 
WebClient 文件上传问题的, 403 禁止WebClient oWebClient new WebClient()oWebClient.Credentials C

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目录中设置

热点排行