創建在從字節數組控制器zip文件和我返回zip文件作爲fileresult。當我下載zip文件並提取文件時,它已損壞。我做這樣說:壓縮文件與dotnetzip,並且當打開時它已損壞
byte[] fileBytes =array
MemoryStream fileStream = new MemoryStream(fileBytes);
MemoryStream outputStream = new MemoryStream();
fileStream.Seek(0, SeekOrigin.Begin);
using (ZipFile zipFile = new ZipFile())
{
zipFile.AddEntry(returnFileName, fileStream);
zipFile.Save(outputStream);
}
outputStream.Position = 0;
FileStreamResult fileResult = new FileStreamResult(outputStream, System.Net.Mime.MediaTypeNames.Application.Zip);
fileResult.FileDownloadName = returnFileName + ".zip";
return fileResult;
下載的文件是否包含任何內容? – mortb
是,包含文件,但是當你打開它已損壞 – user1957868
該文件是一個XML文件,當我打開它,我得到的東西,如:!k來‡Vá2Ž™[CONTENT_TYPES] .XML¢(¼•MOA @†I&þ ‡f¯†.'bŒ¡xðã¨$bâuítÃ[email protected]ø÷n·XA^合肥;ó¾ÏÎt§ƒë¥NU * GOE»[:!©ì''ÏãûÎ%E「•B;²ëáéÉ相反原始xmlf文件 – user1957868