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

feng8317 2010-01-27 10:19:15

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) 已禁止。"
是什么原因,有么有遇到过。
...全文
127 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
xq19900614 2012-07-18
  • 打赏
  • 举报
回复
也就是说 你直接输入地址的话就可以 但是在程序里有问题是吧? 用没用IIS? 如果用IIS的话 你那个Load虚拟目录没有读写权限,我的就是出现这个问题,改了权限就好了。 呵呵 改好了给分哈
feng8317 2010-01-27
  • 打赏
  • 举报
回复
能说的详细点吗
czhenq 2010-01-27
  • 打赏
  • 举报
回复
IIS目录中设置
feng8317 2010-01-27
  • 打赏
  • 举报
回复
http://192.28.22.66/SITEMP/我打开这个路径用ie打开没问题
远程目录能不能写如何判断
czhenq 2010-01-27
  • 打赏
  • 举报
回复
远程目录能写么?
feng8317 2010-01-27
  • 打赏
  • 举报
回复
没人知道吗
mck477 2010-01-27
  • 打赏
  • 举报
回复
我现在也在做这个上传和下载的问题,先顶下
feng8317 2010-01-27
  • 打赏
  • 举报
回复
Stream postStream = oWebClient.OpenWrite("d:\dddddd.bmp " + "dddddddd.bmp", "stor");
改成本地的就没问题
feng8317 2010-01-27
  • 打赏
  • 举报
回复
Stream postStream = oWebClient.OpenWrite("http://localhost/ " + "dddddddd.bmp", "PUT"); 我该成本地的也不行

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧