0

In my application I have byte[] which I am converting to MemoryStream using bellow code.

stream.Write(file, 0, file.Length);
stream.Position = 0;

I am adding this file as ".csv" to zip file attaching that zip file to email.

Attachment attachment;
MemoryStream memoryStreamOfFile = new MemoryStream();
using (ZipFile zip = new ZipFile()) {
 zip.Password = "123456";
 zip.Encryption = EncryptionAlgorithm.WinZipAes256;
 zip.AddEntry(FileName + ".csv", stream);
 zip.Save(memoryStreamOfFile);
 memoryStreamOfFile.Position = 0; 
 attachment = new Attachment(memoryStreamOfFile, new ContentType("application/zip")) {Name = FileName + ".zip"};
} 

Problem is that Zip file is not password protected even I have added password to it & file inside zip file is not created.

I am using "DotNetZip" to create zip file.

Anything wrong I am doing in this ?

vaibhav shah
  • 4,939
  • 19
  • 58
  • 96

0 Answers0