Tallan's Technology Blog

Tallan's Top Technologists Share Their Thoughts on Today's Technology Challenges

Posts Tagged "SMTP"

.NET File Compression in Memory

Karl Schwirz

File compression is nothing new to .NET.  However, in many solutions it requires the developer to establish a file folder which they will write the compressed file to and later read from.
This solution cannot work if you want to compress and use the file in memory without writing to disk.  An example of this could be on a server where you don’t particularly want to have random processes writing to and reading files.
Listed below is a solution we came up with for compressing a file in memory. We used an open source library SharpZipLib from sharpDevelop.net.  There are other good options out there that could also be used.  We found that using this library offered the most intuitive solution to creating the archive file.
The result will be a Stream which can be used to send the compressed data to an…