[英]Could not find file 'C:\Program Files (x86)\IIS Express\GraceCancerFoundation.png'
[英]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");
}
}
}
}
錯誤詳情
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]
至少需要一些列表參數。
在閱讀之前建議 File.Exists(filePath) 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.