|
I wanna unzip some zip files , but I got this error:
Could not find a part of the path 'D:\Inetpub\wwwroot\fanavadc\cache\blue\content.css'
amazing thing for me is I can unzip some file.can u help me?
HRT
|
|
|
|
|
Hi,this is a good stuff .Bt zipped files size is same as the total size of the zipped files.Can you suggest me wat should i do to get some compressed in size for zip file.
|
|
|
|
|
Hi,
I just check the project from Valeri EasyZipUnzip_Demo, that what I'm looking for.
Unfortunetly I wish to zip and unzip files with password, is it possible?
Thanks in andvance.
Naim
|
|
|
|
|
Hi,
There is no support for password-protected files. You could create your own encryption mechanism using the classes in the System.Security.Cryptography namespace. If you do this, be aware that the resulting file will not be compatible with standard Zip utilities such as WinZip.
With best regars,
Valeri
|
|
|
|
|
Can we unzip the files using ur code.
by writing revers?
|
|
|
|
|
Yes. Did you look my code?
|
|
|
|
|
Hi,
Thanks for the article. By the way how can we unzip password protected zip files - would be of great help if you could let me know.
Thanks and Regards,
Venkatesh.
|
|
|
|
|
Hi,
There is no support for password-protected files.
With best regards,
Valeri
|
|
|
|
|
Short and to the point. Thanks!
--
Ubi Signo?
|
|
|
|
|
How can we unzip password-protected files.
|
|
|
|
|
We have thousands and thousands of zip files on our server. I have written a program that opens up these zip files and extracts certain files from them (i.e, *.doc files). I have been doing this over VPN, and it is much slower than going into the office. Most of the time I only need one .DOC file that is in a 5 or 10MB zip, and it happens to be the last file stored in most of the zips. What is happening is that the program is reading the zip file until it finds a file it wants and then extracts only that file. The problem is since these files are stored at the end of the .ZIP, it takes many minutes for it to iterate through all of the files that are in the ZIP (even though I don't want to do anything with them, or try to read them, etc...) and it just takes a while.
I am wondering if ZIP stores the file contents in a header, and if it does, if it is possible to just read that header, figure out what files you need and what byte offset it is at and then "skip" right to that file without reading the entire zip file? This would make my helper application a million times faster. I've looked around for other solutions but I can't seem to see any that can do it, it appears as if this Java class needs to read the contents of the entire file to get you what you want.
Thanks!
|
|
|
|
|
ZIP stores the file information at the end of .zip. It reads this information first to know where to get the file.
|
|
|
|
|
ahh, that explains it!
so does the library actually read every byte until it finds the header, or does it do skipping around?
just curious as to if there is some way around reading the entire file to get a file that is at the beginning (probably not, but the many hours and hours saved if there is is worth the post!)
thanks for the reply .. oh and by the way, thanks for the POST. I looked and looked and never could have imagined it being so easy!
S
|
|
|
|
|
I studied your article "Zip and Unzip from a C# program using J# runtime" and it is quite helpful.
But i am getting problem that if a zip folder containes andother zip folder or a folder named *.rar then
"java.util.zip.ZipEntry ze = new java.util.zip.ZipEntry(sourceFile);"
za dont get it correctly and throws and exception.
If you can help me pleez to get out of it.
Regards.
M.Ali.Raza
|
|
|
|
|
java.util.zip.ZipEntry does not support fileNames like "deAlarcón.doc"
What can i do? thank's
|
|
|
|
|
Hello
As vjslib is buggy (don't use it) try this one:
http://www.icsharpcode.net/OpenSource/SharpZipLib/
There are 3 advantegaes over vjslib:
1.) It works without bugs.
2.) It also supports GZip, Tar and BZip2 .
3.) The DLL you need is only 140 kB instead of 3,7 MB.
The SharpZipLib has a good detailed documentation but it lacks examples.
So I post my code here which I use to zip a whole folder into a ZIP file.
Elmü
using ICSharpCode.SharpZipLib.Zip;
static public void PackFolderIntoZipFile(string s_Folder, string s_ZipFile)
{
ZipOutputStream i_zStream = new ZipOutputStream(File.Create(s_ZipFile));
i_zStream.SetLevel(5);
int s32_BaseFolderLen = s_Folder.Length;
if (s_Folder.Substring(s_Folder.Length-1) != "\\") s32_BaseFolderLen ++;
ArrayList i_FileList = new ArrayList();
EnumFiles(ref i_FileList, s_Folder, "*.*", true);
Byte[] u8_Buf = new Byte[0x100000];
foreach (string s_File in i_FileList)
{
FileStream i_fStream = null;
try { i_fStream = File.OpenRead(s_File); }
catch { continue; }
string s_ZipPath = s_File.Substring(s32_BaseFolderLen).Replace("\\", "/");
ZipEntry i_ZipEntr = new ZipEntry(s_ZipPath);
FileInfo i_Info = new FileInfo(s_File);
i_ZipEntr.DateTime = i_Info.LastWriteTime;
i_zStream.PutNextEntry(i_ZipEntr);
while (true)
{
int s32_Len = i_fStream.Read(u8_Buf, 0, u8_Buf.Length);
if (s32_Len <= 0)
break;
i_zStream.Write(u8_Buf, 0, s32_Len);
}
i_fStream.Close();
}
i_zStream.Finish();
i_zStream.Close();
}
static public void EnumFiles(ref ArrayList i_FileList, string s_Path, string s_Filter, bool b_Subfolders)
{
if (s_Path == null || s_Path == "")
return;
string[] s_Files = Directory.GetFiles(s_Path, s_Filter.Trim());
foreach (string s_File in s_Files)
{
i_FileList.Add(s_File);
}
if (b_Subfolders)
{
string[] s_Dirs = Directory.GetDirectories(s_Path);
foreach (string s_Dir in s_Dirs)
{
EnumFiles(ref i_FileList, s_Dir, s_Filter, true);
}
}
}
|
|
|
|
|
Hello,
Thanks for this rather useful piece of code. What about zipping multiple folders with their subfolders in 1 archive?
-Drago
|
|
|
|
|
Hello
This is quite a useless question.
If you would have studied and understood my code you should be able to answer this question on your own!
Simply call
EnumFiles(ref i_FileList, s_Folder, "*.*", true);
once for each folder you want to add !
Thats all !
Elmü
|
|
|
|
|
Nice work.. Though you could use a little manners training
|
|
|
|
|
I attempted to use the SharpZipLib with the .NET 2.0 Framework and Visual Studio 2005 C# windows project and the result I got were very poor. I was able to compile and build zip files that were always currupted. I used their sample project called “SharpZipLib\samples\cs\CreateZipFile” and compilied it with the dll obtained from the .NET 2.0 download. I then proceeded to use the library with a bunch of .cs, .snk, .shfb, and .xml files and the resulting ZIP file was always currupted. Doing the same thing with the java library seems to be working just great.
Chris
|
|
|
|
|
Hi Valeri, I have finally came out with the algorithm to zip a particular folder and it's content which includes the subfolders and the files that are located in both the folder and the subfolders.
I have been searching for an example to zip a folder without using the opensource library (SharpZipLib) but I can't find any. Then, I decided to write the codes myself in the end. It took me a few lines to do both zip and unzip folder operation as well as zipping and unzipping files. wooohoooo yay.
I shall share my codes to the codeproject.com viewers soon.
|
|
|
|
|
Hi Can I have the code pls
Obinna_eke@hotmail.com
|
|
|
|
|
could you please share ur code.
|
|
|
|
|
Hi, Valeri,
I have gone through your codes and they are working fine. This app is to zip files only. How about folders ?
Do you have any examples to zip folders and their subdirectories ?
Thank you.
|
|
|
|
|
I left out something in the previous thread.
Do you have any examples on zipping folders and their subdirectories together with the files ?
Thanks.
|
|
|
|