自己做的網站﹐上傳excel后﹐當下載的時候出現這個錯誤.如果您是使用[檔案]功能表最下方的最近使用檔案清單來開啟檔案 
 找不到'C:\Documents and Settings\mis31\Local Settings\Temporary Internet File\***省略\%e8%e88...xls'
如果您是使用[檔案]功能表最下方的最近使用檔案清單來開啟檔案,請檢查這個檔案是否已被更新名稱
,移動至其他地方或刪除謝謝@ 
client 報告的錯誤我用datalist綁定的資料庫的文件信息
下載文件, 文件是的確存在的。﹗
可以保存﹐但是不能直接打開! 有的文件可以打開﹐有的不可以呀
圖片文件
http://handandaily.googlepages.com/ExcelFile.jpg

解决方案 »

  1.   

    原來的topic
    http://community.csdn.net/Expert/topic/5254/5254843.xml?temp=.903805
      

  2.   

    try:if(!File.Exists(srcFile))
    {
    throw new Exception("file were not found.");
    }string filename = Path.GetFileName(srcFile);Response.ContentType = "Application/ms-excel";
    Response.AddHeader("Content-Disposition",String.Concat("Attachment;filename=",HttpUtility.UrlEncode(filename,System.Text.Encoding.UTF8)));Response.WriteFile(filename);
    Response.End();------说错了莫怪。
      

  3.   

    http://support.softartisans.com/files/support/images/error-filenotfound.jpg
    這是圖片.
    提示的信息和這個一樣.!
    文件夾是自動生成的﹐﹗根據類別﹗上面的代碼我試過了不可以
    我想是不是文件名稱過長導致的這個錯誤﹐別的文件就可以﹐就一個文件不可以直接打開﹗
      

  4.   

    這是英文的相關信息和答案﹐但是也沒有解決問題
    http://support.softartisans.com/kbview.aspx?ID=895
      

  5.   

    請求高人翻譯:Solution 
    This problem can caused by the server sending HTTP response headers that tell the browser not to cache the response. It is common for developers to configure ASP or ASP.NET applications this way because they contain dynamic content. Telling the browser not to cache the page ensures it will always make a new request to the server and get the most up-to-date version of the page. However, in a page which generates an Excel file and streams it to the client, it is better NOT to turn off client-side caching because the file needs to stay around long enough for the browser to pass it to Excel. Even if the server has told the browser not to cache the file, the actual behavior may be different on different client machines. On certain clients, the temp file will remain long enough for Excel to open it. But on some client configurations, the spreadsheet gets deleted immediately by the operating system and Excel will not be able to find it. The HTTP headers which control client-side caching may have been set either in your ASP or ASP.NET code or in IIS. The solution is to turn off these HTTP headers, either by removing the lines of code, or disabling the settings in IIS. In Your Code
    By default, ASP and ASP.NET do not add any headers to control browser caching behavior. If the headers have been set in your page, you will see some combination of the following lines of code: 
    Response.CacheControl = "no-cache"
    Response.AddHeader "Pragma", "no-cache"
    Response.Expires = -1
    If you see these lines of code in your ExcelWriter page, remove them. In IIS
    The default IIS settings for a virtual directory do not cause the generation of HTTP headers that affect client-side caching behavior. However, if you are experiencing this problem and there is nothing in your code, it is a good idea to check IIS. If IIS settings are causing the headers to be generated, you will see something like this in the "HTTP Headers" tab in the properties dialog of your virtual directory: 
     
    To turn off these settings, uncheck "Enable Content Expiration" If you prefer to keep the "Enable Content Expiration" settings for all your other non-ExcelWriter pages, you can do the above step in the "properties" dialog for the specific ExcelWriter page rather than for the application as a whole. 
      

  6.   

    你这种情况应该是文件流没有缓存在IE临时文件夹中,应该是代码 :Response.CacheControl = "no-cache" 问题,你把此句拿掉试试!
      

  7.   

    请参考我一个程序的代码:
    //下载Log,目前还有一BUG就是下载时,当选择“打开”文件时,在IE缓存中已被清除!!
    //只需把 Response.CacheControl="no-cache"去掉就OK;
    public void Down(object sender, EventArgs e)
    {  
    System.Web.UI.WebControls.Button button=((Button)sender);
    System.Web.UI.WebControls.TableCell tc=(System.Web.UI.WebControls.TableCell)(button.Parent);
    System.Web.UI.WebControls.DataGridItem item=(System.Web.UI.WebControls.DataGridItem)(tc.Parent); string FileFullName=item.Cells[9].Text;
    string sFileName = "\\WebSpace\\Upload\\BackupLog\\"+FileFullName;  //此处注意前后的 "\\"符号!
    Response.Clear();
    System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath(sFileName));
    string s=file.DirectoryName.ToString();
    if (file.Exists)
    {
    Response.Buffer = true;
    Response.ContentType = "application/octet-stream";
    //加UrlEncode是为了对付文件名为中文的情况,防止出现乱码
    Response.AddHeader("Content-Disposition", "attachment;FileName=" +        HttpUtility.UrlEncode(file.Name, System.Text.Encoding.UTF8));
    Response.AddHeader("Content-Length", file.Length.ToString());
    Response.WriteFile(file.FullName);
    }
    else
    Response.Write("此文件不存在,可能被重命名或者被删除!");
    Response.End();
    this.Dispose();
    }
    =========搞定了没有?OK的话,放分,呵呵!
      

  8.   

    讓我試一下
    我沒寫Response.CacheControl="no-cache"
    代碼﹗
      

  9.   

    不可以呀.!
    我猜想是不是文件名稱過長導致的問題﹐
    經過UrlEncode之后文件名全部是%a1%14%....好多﹐我猜想是不是文件名稱過長﹗