Hi,
I have multiple files, file’s path is not there as it is dynamic but i have there byte data. i want to zip also those files. How can i achieve this requirement?
var zipFilePath = "C:\\Projects\\Own\\LZMACompression_out.zip";
FileInfo fi1 = new FileInfo("C:\\Projects\\Own\\alice29.txt");
//FileInfo fi2 = new FileInfo("fields.c");
using (zipFile = File.Open(zipFilePath, FileMode.Create))
{
using (Archive archive = new Archive(new ArchiveEntrySettings(new LzmaCompressionSettings())))
{
archive.CreateEntry("alice29.txt", fi1);
archive.Save(zipFile, new ArchiveSaveOptions() { Encoding = Encoding.ASCII });
}
}
I tried this code but it keeps giving me this below error when i extract zip folder
image.png (11.4 KB)
Hello @Amrinder_Singh
You can compress your data from memory providing memory stream with those bytes:
byte[] bytes = ...
using (FileStream zipFile = File.Open("LZMACompression_out.zip", FileMode.Create))
{
using (MemoryStream source = new MemoryStream(bytes))
{
using (var a = new Archive(new ArchiveEntrySettings(new LzmaCompressionSettings())))
{
a.CreateEntry("first", source);
a.Save(zipFile);
}
}
}
What tool are you using to extract composed archive?