简体   繁体   English

System.IO.FileNotFoundException: '找不到文件'C:\Program Files (x86)\IIS Express\files'。

[英]System.IO.FileNotFoundException: 'Could not find file 'C:\Program Files (x86)\IIS Express\files'.'

public HttpResponseMessage DownloadZipFile(List<FileModel> files)
{
    HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

    using (ZipFile zip = new ZipFile())
    {
        zip.AlternateEncodingUsage = ZipOption.AsNecessary;
        zip.AddDirectoryByName("Files");

        foreach (FileModel file in files)
        {
            if (file.IsSelected)
            {
                //byte[] buffer = new byte[4096];
                byte[] fileBytes = System.IO.File.ReadAllBytes("files");
                string s = Convert.ToBase64String(fileBytes);

                zip.AddFile(file.FilePath, "Files");
            }
        } 
    }
}

Error Details错误详情

System.IO.FileNotFoundException   HResult=0x80070002   Message=Could not find file 'C:\Program Files (x86)\IIS Express\files'.   Source=<Cannot evaluate the exception source>  
StackTrace: <Cannot evaluate the exception stack trace>

This exception was originally thrown at this call stack:
[External Code]
ZIpFile_Creation_API.Controllers.ZipAPIController.DownloadZipFile(System.Collections.Generic.List<ZIpFile_Creation_API.Models.FileModel>) in ZipAPIController.cs
[External Code]

atleast needs some List param.至少需要一些列表参数。

suggesting File.Exists(filePath) before reading.在阅读之前建议 File.Exists(filePath) 。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到文件“C:\\Program Files (x86)\\IIS Express\\GraceCancerFoundation.png” - Could not find file 'C:\Program Files (x86)\IIS Express\GraceCancerFoundation.png' 错误:“找不到文件&#39;C:\\ Program Files(x86)\\ IIS Express \\ button.png&#39;” - Error : `Could not find file 'C:\Program Files (x86)\IIS Express\button.png'` 找不到路径“C:\\Program Files (x86)\\IIS Express\\~\\TextFiles\\ActiveUsers.txt”的一部分 - Could not find a part of the path 'C:\Program Files (x86)\IIS Express\~\TextFiles\ActiveUsers.txt' VS 2012和IIS Express。 找不到路径“ C:\\ Program Files(x86)\\ IIS Express \\〜\\ MyPics \\ My.jpg”的一部分 - VS 2012 & IIS Express. Could not find a part of the path 'C:\Program Files (x86)\IIS Express\~\MyPics\My.jpg' System.IO.FileNotFoundException:找不到文件 - System.IO.FileNotFoundException : Could not find file 找不到文件&#39;C:\\ Program Files(x86)\\ Common Files \\ Microsoft Shared \\ DevServer \\ 10.0&#39; - Could not find file 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0' WebApi,文件存在但未找到文件,IIS始终从“ C:\\ Program Files(x86)\\ IIS Express”文件夹中读取 - WebApi, File exists but file not found, IIS always reads from “C:\Program Files (x86)\IIS Express” folder System.IO.FileNotFoundException: 找不到文件 &#39;x\\x\\x\\x\\bin\\debug\\project.dll - System.IO.FileNotFoundException: Could not find file 'x\x\x\x\bin\debug\project.dll 拒绝访问路径“C:\\\\Program Files (x86)\\\\IIS Express\\\\Excel.xlsx” - Access to the path 'C:\\Program Files (x86)\\IIS Express\\Excel.xlsx' is denied Xamarin Android System.IO.FileNotFoundException:找不到文件异常 - Xamarin Android System.IO.FileNotFoundException: Could not find file Exception
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM