RE: Adding files entries to zipfiles in ax 2012
Hi Nikolaos Mäenpää,
I did try using different zip extractors. I think the file that is being created using that function has issues. When I use file stream classes and add files to zip, it works fine.
Or maybe I am not using the function properly.
Here is example of what I used:
str zipPath = @"C:\Users\vgubba\start.zip";
str newFile = @"c:\users\vgubba\TEST.pdf";
archive=System.IO.Compression.ZipFile::Open(zipPath, System.IO.Compression.ZipArchiveMode::Create);
System.IO.Compression.ZipFileExtensions::CreateEntryFromFile(archive,newFile, "TEST1.pdf");
archive.Dispose();
However the below code works:
zipArchive = System.IO.Compression.ZipFile::Open(zipPath, System.IO. Compression.ZipArchiveMode::Create);
fileEntry = zipArchive.CreateEntry("TEST1.pdf");
fileEntryStream = fileEntry.Open();
fileStream = System.IO.File::Open(newFile,System.IO.FileMode::Open);
fileStream.CopyTo(fileEntryStream);
fileStream.Close();
fileEntryStream.Close();
zipArchive.Dispose();
Thanks,
Vaishnavi.