上传错误 F:\media_group\service\ServiceControl\upload\zhangxq
System.ObjectDisposedException: Cannot access a closed file. at System.IO.__Error.FileNotOpen() at System.IO.FileStream.Seek(Int64 offset, SeekOrigin origin) at System.Web.HttpRawUploadedContent.TempFile.GetBytes(Int32 offset, Int32 length, Byte[] buffer, Int32 bufferOffset) at System.Web.HttpRawUploadedContent.WriteBytes(Int32 offset, Int32 length, Stream stream) at System.Web.HttpInputStream.WriteTo(Stream s) at System.Web.HttpPostedFile.SaveAs(String filename) at file_upload.Upload_ServerClick(Object sender, EventArgs e) in f:\media_group\service\ServiceControl\file_upload.aspx.cs:line 131这是报错信息。
System.ObjectDisposedException: Cannot access a closed file. at System.IO.__Error.FileNotOpen() at System.IO.FileStream.Seek(Int64 offset, SeekOrigin origin) at System.Web.HttpRawUploadedContent.TempFile.GetBytes(Int32 offset, Int32 length, Byte[] buffer, Int32 bufferOffset) at System.Web.HttpRawUploadedContent.WriteBytes(Int32 offset, Int32 length, Stream stream) at System.Web.HttpInputStream.WriteTo(Stream s) at System.Web.HttpPostedFile.SaveAs(String filename) at file_upload.Upload_ServerClick(Object sender, EventArgs e) in f:\media_group\service\ServiceControl\file_upload.aspx.cs:line 131这是报错信息。
<system.web>
<httpRuntime executionTimeout="90" maxRequestLength="20000"/>
</system.web>
http://channel9.msdn.com/ShowPost.aspx?PostID=106570
ASP.Net 2.0 - Uploading file exception
服务器是win2003+iis6.0
注意上传文件夹必须要有读写权限,特别对于IIS来宾帐户.具体的可以参考一下:
http://www.hiwiz.com/ViewNews.aspx?nc_id=CSHARP&nws_id=1896
http://www.hiwiz.com/ViewNews.aspx?nc_id=CSHARP&nws_id=1026
http://www.hiwiz.com/ViewNews.aspx?nc_id=CANDCJJ&nws_id=19722
是HttpWebResponse的问题,它每次响应后应该即时关闭连接,若不然它会影响后面的。折腾我几天的问题于刚才得到解决!!
看看你是不是这个问题。http://www.knowsky.com/341483.html这个讲解的详细。
我没用这个。
我使用HIF.PostedFile.SaveAs(baseLocation +"\\"+ fn);
我看你的错误跟我的不一样。
你的好像是使用哪个文件没有关闭的意思。(英文很烂呃)
Stream stream = response.GetResponseStream();
byte[] buf = new byte[100];
stream.Read(buf, 0, buf.Length);
stream.Close();//stream没有关闭才引起HttpWebRequest没有响应