用FileStream写下载通过局域网下载时抛出System.ObjectDisposeException异常,请各位老大帮忙
用FileStream写下载通过局域网下载时抛出fs.Length引发System.ObjectDisposeException异常具体如下:
string fileName = Server.MapPath("~/document/EXCEL文件.xls");
FileInfo DownloadFile = new FileInfo(fileName);
HttpResponse Response = HttpContext.Current.Response;
Response.Clear();
Response.ClearHeaders();
Response.Buffer = false;
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(Path.GetFileName(fileName), System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
FileStream fs = new FileStream(filePath, FileMode.Open);
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
fs.Close();
Response.End();
结果抛出fs.Length引发system.ObjectDisposeException异常,真是怪事,下载不了,但是本地却可以下载。 --------------------编程问答-------------------- 请问一下你是否在放在updatePanel中了,如果是请将它去掉
一般出现此原因:一:字符有错误
二:放在了面板当中 --------------------编程问答-------------------- 谢谢,没放updatepanel,字符没错,本地可以,网络上不行。
补充:.NET技术 , ASP.NET