NET Core 1. Toggle navigation Stephen Cleary. Blog Book Projects Publications Contact. NET Core! There are also some others, which form a hierarchy of result types: The FileResult base type has several derived types, each with a different purpose: PhysicalFileResult sends an on-disk file identified by a physical path.
VirtualFileResult sends a file identified by a virtual path. FileContentResult sends the file content as an in-memory byte array. FileStreamResult sends the file content as a stream.
CreateEntry kvp. GetStreamAsync kvp. Value await stream. The zip file is not held in memory. It is streamed directly to the client, compressing on-the-fly.
For large files, not even a single file is read entirely into memory. Each file is individually compressed on-the-fly. Code A fully-working solution for ASP. About Stephen Cleary. This example only lets you add files to an archive and extract all of the files in the archive.
DotNetZip allows you to do other things like dig through a Zip file and extract only certain files. It also has AddProgress and ExtractProgress event handlers to let you know how a long operation is progressing. The following code shows how the program adds the file to the archive. The code in the using block is all there is to actually adding the file to the archive. The rest of the code updates the display and handles exceptions. This code creates the ZipFile object representing the archive and uses its AddFile method to add the file to it.
C Helper. Skip to content. Using the Library To use the library, create a new program. How the Example Works The following code shows how the program adds the file to the archive. AddFile txtFileName. Text, txtPathInArchive. Text ; lblOriginalSize. Text ; lblCompressedSize. ToString " , " ; MessageBox. Begin ; zip. Improve this question. Ricardo Altamirano IF the memory-stream is zip data wouldn't you expect it to be unreadable?
Have you tried to save the memory stream to a file and verified that the conent of that file differs from the file when you save it to file directly from ZipFile? Sam I am - I am taking the memory stream and sending it as an attachment called test. Then went I get it I thought I should be able to treat it as a regular zip file. Am I wrong in thinking this? I don't know what I'm doing wrong though. Show 1 more comment. Active Oldest Votes.
Ok, I figured out my problem, pretty stupid actually. Thanks for everyone's help! Begin ; ms. Flush ;. Improve this answer. Instead of last two lines a Using-statment should be used over ms. Add a comment. Save ms ; line ms.
ToArray ; File.
0コメント