C# Read file from zip file to string
public void ReadFromZipFile()
{
string sampleZipFile = @"C:\temp\myzip.zip";
string result;
using (MemoryStream memory = new MemoryStream())
{
using (ZipFile zip = ZipFile.Read(sampleZipFile))
{
ZipEntry e = zip["myfile.txt"];
e.Extract(memory);
}
using (StreamReader reader = new StreamReader(memory))
{
memory.Seek(0, SeekOrigin.Begin);
result = reader.ReadToEnd();
}
}
Console.WriteLine(result);
}
{
string sampleZipFile = @"C:\temp\myzip.zip";
string result;
using (MemoryStream memory = new MemoryStream())
{
using (ZipFile zip = ZipFile.Read(sampleZipFile))
{
ZipEntry e = zip["myfile.txt"];
e.Extract(memory);
}
using (StreamReader reader = new StreamReader(memory))
{
memory.Seek(0, SeekOrigin.Begin);
result = reader.ReadToEnd();
}
}
Console.WriteLine(result);
}
My friend gave important doc file in zip archive,but unfortunately file was damaged.But after two days one familiar advised-all zip for recovery software.As he said tool helped him in like condition and program has free status.Besides that utility extract data from corrupted files with *.zip extension.
ReplyDeleteI often join my zip files and once I did it and both files were deleted!I didn't know what to do.But I used next tool-best recovery zip software,which I found in one forum and tool solved my problem.Moreover it is free and can too extract data from corrupted files with *.zip extension.
ReplyDelete