[英]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.