upload上傳文件的問題

yurenseven 2003-08-21 08:45:40
大俠們好:
我在c#中利用
System.Net.WebClient upload = new System.Net.WebClient();
byte[] responseArray = upload.UploadFile
("\\d:/BarCode.ocx","POST","BarCode.ocx");
上傳文件沒有任何問題,但是我利用
System.Net.WebClient upload = new System.Net.WebClient();
byte[] responseArray = upload.UploadFile("http://localhost/iis/BarCode.ocx","POST","BarCode.ocx");
上傳文件的時候出現如下錯誤:"The remote server returned an error: (405) Method Not Allowed."
請問應該怎麽解決?
...全文
63 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
smiletosky 2003-08-21
  • 打赏
  • 举报
回复
楼上,我是winform的
dragontt 2003-08-21
  • 打赏
  • 举报
回复
to 楼上的
还有一种方法
.net对inputfile这个控件提供了便捷的方式

片断代码如下:
// Get a reference to PostedFile object
HttpPostedFile myFile = itemFile.PostedFile;

// Get size of uploaded file
int nFileLen = myFile.ContentLength;

if( nFileLen == 0 )
{
this.AddMessage( "上传资料为空!" );
return;
}

// Allocate a buffer for reading of the file
byte[] myData = new byte[nFileLen];

// Read uploaded file from the Stream
myFile.InputStream.Read(myData, 0, nFileLen);
smiletosky 2003-08-21
  • 打赏
  • 举报
回复
yurenseven (雨人) ,问一下
我上传一直没成功,说没有权限什么的,你的怎么 做的

110,533

社区成员

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

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

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