Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 26, 2012 05:46 AM by likeaboss
Member
2 Points
4 Posts
Dec 25, 2012 12:16 PM|LINK
UP!Help please me!
I was use ICSharpCode.SharpZipLib.dll to compress files.
And now, how to recompress&
public static void WriteZipFile(List<string> filesToZip, string path, int compression) { //if (compression < 0 || compression > 9) // throw new ArgumentException("Invalid compression rate."); //if (!Directory.Exists(new FileInfo(path).Directory.ToString())) // throw new ArgumentException("The Path does not exist."); foreach (string c in filesToZip) if (!File.Exists(c)) throw new ArgumentException(string.Format("The File{0}does not exist!", c)); ZipOutputStream stream = new ZipOutputStream(File.Create(path)); stream.SetLevel(compression); for (int i = 0; i < filesToZip.Count; i++) { ZipEntry entry = new ZipEntry(Path.GetFileName(filesToZip[i])); entry.DateTime = DateTime.Now; var md5 = MD5.Create(); using (FileStream fs = File.OpenRead(filesToZip[i])) { byte[] buffer = new byte[fs.Length]; byte[] cheksum = md5.ComputeHash(fs); fs.Read(buffer, 0, buffer.Length); entry.Size = fs.Length; fs.Close(); entry.Crc = Convert.ToUInt32(cheksum); stream.PutNextEntry(entry); stream.Write(buffer, 0, buffer.Length); } } stream.Finish(); stream.Close(); }
Contributor
5514 Points
810 Posts
Dec 25, 2012 05:19 PM|LINK
Refer this
http://blog.logiclabz.com/c/unzip-files-in-net-c-using-sharpziplib-open-source-library.aspx
http://www.codeproject.com/Articles/20493/Make-a-Zip-UnZip-Software-using-SharpZipLib
Dec 26, 2012 05:46 AM|LINK
Thank you!
But I used cheksum.and how i can unzip files?which was ziping by cheksum
likeaboss
Member
2 Points
4 Posts
Unzip files using c# code
Dec 25, 2012 12:16 PM|LINK
UP!Help please me!
I was use ICSharpCode.SharpZipLib.dll to compress files.
And now, how to recompress&
public static void WriteZipFile(List<string> filesToZip, string path, int compression) { //if (compression < 0 || compression > 9) // throw new ArgumentException("Invalid compression rate."); //if (!Directory.Exists(new FileInfo(path).Directory.ToString())) // throw new ArgumentException("The Path does not exist."); foreach (string c in filesToZip) if (!File.Exists(c)) throw new ArgumentException(string.Format("The File{0}does not exist!", c)); ZipOutputStream stream = new ZipOutputStream(File.Create(path)); stream.SetLevel(compression); for (int i = 0; i < filesToZip.Count; i++) { ZipEntry entry = new ZipEntry(Path.GetFileName(filesToZip[i])); entry.DateTime = DateTime.Now; var md5 = MD5.Create(); using (FileStream fs = File.OpenRead(filesToZip[i])) { byte[] buffer = new byte[fs.Length]; byte[] cheksum = md5.ComputeHash(fs); fs.Read(buffer, 0, buffer.Length); entry.Size = fs.Length; fs.Close(); entry.Crc = Convert.ToUInt32(cheksum); stream.PutNextEntry(entry); stream.Write(buffer, 0, buffer.Length); } } stream.Finish(); stream.Close(); }Vipindas
Contributor
5514 Points
810 Posts
Re: Unzip files using c# code
Dec 25, 2012 05:19 PM|LINK
Refer this
http://blog.logiclabz.com/c/unzip-files-in-net-c-using-sharpziplib-open-source-library.aspx
http://www.codeproject.com/Articles/20493/Make-a-Zip-UnZip-Software-using-SharpZipLib
likeaboss
Member
2 Points
4 Posts
Re: Unzip files using c# code
Dec 26, 2012 05:46 AM|LINK
Thank you!
But I used cheksum.and how i can unzip files?which was ziping by cheksum