 |
|
 |
I can't get this code or any variation to run since the Process.Start call throws an exception that it can't find the file. The Current AppDomain is the folder that I started my app out of and it obviously doesn't have those two executables. How is this supposed to work?
Puzzled.
- Lutz
|
|
|
|
 |
|
 |
I just downloaded the zip file included with this article and there are two zip.exe files in there.. just look around.
|
|
|
|
 |
|
 |
I want Password protected zip file is this example support password protedted file?
Shahzad Aslam
Software Engineer
Softech Systems Limited
Email: shehzadaslam@hotmail.com
|
|
|
|
 |
|
 |
1. the 2 code examples - are the related somehow ?
2. if i use the shell example and i need to know when the zipping ends, how can i do that? (is there anyway to get the thread name that it makes or something)
thanks
|
|
|
|
 |
|
 |
Hello,Thanks for excellent Code
Can I ask you 2 question?
1)I don't understand How works Unzip procedure..Can you make an example?
2)I need to know when zip process ends...How can I?
Thanks
Carlo Ingrassia
|
|
|
|
 |
|
|
 |
|
 |
Hello. Thanks for making your code available. I don't doubt that it compresses the file. However, I don't see anything in the code that indicates that it is actually compressing the file rather than just copying it. Does the Shell32.Folder.CopyHere method implicitly compress the file being copied?
Thanks again!
|
|
|
|
 |
|
 |
Yes copying files into a ziped folder automatically compresses the files.
|
|
|
|
 |
|
 |
Hi Gerald,
You have created an excellent utility and it is running fine.
Can I use this utility on my application? Is it Free?
Thanks,
Gopal
|
|
|
|
 |
|
 |
100% free. Of coarse if you want to feed my ego by adding a mention of this web page or my website GeraldGibson.Net then all the better!
Thanks for taking the time to try this out and then comment.
|
|
|
|
 |
|
 |
For compressing (and decompressing utilizing both your editorials), I find that it cannot be done. The program crashes. I used your sample code. I compiled it with VS 2003 and 2005 and it crashes when attempting to zip. I created my own code and it also crashes based on the sample codes given in your editorial, but not straight from the source code. I debugged to the point where it crashes. For instance:
byte[] emptyzip = new byte[] { 80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
FileStream fs = File.Create(AppDomain.CurrentDomain.BaseDirectory + "\\data.zip");
fs.Write(emptyzip, 0, emptyzip.Length);
fs.Flush();
fs.Close(); // works
Shell32.ShellClass sc = new Shell32.ShellClass();
Shell32.Folder DestFlder = sc.NameSpace(AppDomain.CurrentDomain.BaseDirectory + "\\data.zip"); // problem
Shell32.Folder SrcFlder = sc.NameSpace(textBoxattachment.Text); // WORKS
Shell32.FolderItems items = SrcFlder.Items(); // WORKS
DestFlder.CopyHere(items, 8);
System.Threading.Thread.Sleep(1000);
Anything that the Shell32.Folder looks at a file .zip, it would crash the program. Now if it was a regular folder inserted for the DestFlder, then it would work, no crashes, copyhere works. Inject anything with .zip and it won't work. I have Windows XP w/SP2 and WinRAR registered to take care of .zip files. Don't exactly know why DestFlder fails if it has a pointer at some zip file as the destination. Any ideas?
|
|
|
|
 |
|
 |
I remember in the comments in one of the articles that someone had a similar problem caused by not copying a Interop file into the same folder as the app doing the ziping. You may want to look to see if this is the issue you are having.
|
|
|
|
 |
|
 |
When compiling, I see in my debug/release folders that the Interop.Shell32.dll file exists. Shell32 is properly linked in the source code, hence Interop was created, I presume by so. And so does your sample source code too, contains the Interop file. So I'm at the point where I don't know why as it keeps crashing when it looks for the .zip file and won't accept it. Any other ideas?
Gerald Gibson Jr wrote: I remember in the comments in one of the articles that someone had a similar problem caused by not copying a Interop file into the same folder as the app doing the ziping. You may want to look to see if this is the issue you are having.
|
|
|
|
 |
|
 |
What I just did was went to where I keep my sample for this project and copied out of the debug folder three files to a directory called c:\test\testzip\
In this folder I copied these files: Sample.exe, zip.exe, Interop.Shell32.dll
Then I double clicked the Sample.exe and filed in the three input boxes and clicked the Zip button.
That worked correctly.
You may want to try this same test. Also at http://GeraldGibson.Net I have a somewhat newer version of this article posted which you may want to try out. Also I dont see why it would cause an issue but in your code where it says... AppDomain.CurrentDomain.BaseDirectory + "\\data.zip". You may want to try removing the \\
|
|
|
|
 |
|
 |
Removing the double back slashes didn't do anything. It has to do with the call to storing the destination to a zip file. Copy the three files to an isolated folder as such suggested did not work. I get this error mssage from your sample:
zip.exe - Common Language Runtime Debugging Services
Application has generated an exception that could not be handled.
Process id=0xe54 (3668), Thread id=0xca4 (3236).
Click OK to terminate the application.
Click CANCEL to debug the application.
That's it. So I have no clue what's going on. I doubt you've experienced this error before though. I'm still puzzled why it works for many others, but I have yet to find anybody else having the same problem as me on the Internet when I search for my problem.
|
|
|
|
 |
|
 |
Well the one thing that was floating around in the back of my mind was you said you have another app registered as the zip handler in Windows? Maybe that is the problem. Perhaps that other app is some how interfering with the Shell API? Try to do this test on another PC.
|
|
|
|
 |
|
 |
Thanks for publishing this code. I'm using it to do daily backup from my laptop to box.net (a free storage site).
I recommend that anyone get the newer code from your web site (listed in the comments here)
http://geraldgibson.net/dnn/Home/CZipFileCompression/tabid/148/Default.aspx[^]
ian rae at http://silentsoftware.blogspot.com/
|
|
|
|
 |
|
 |
Thank you for your comments. I tried four or five different methods to get a free version of this working before I finally came up with this code. It is a nice balance of control and free
http://GeraldGibson.Net
|
|
|
|
 |
|
 |
I've been using this code for about 3 months now for our automation efforts. We run nightly builds on several products and use this zip functionality as part of sending the results to testers via e-mail. The reliability has been excellent and I have not had to modify the code since initial use/modification.
Thanks Gerald!
|
|
|
|
 |
|
 |
Thanks for the comment. It helps keep me motivated to put out more and more code. I am working on some other stuff that I am posting at my GeraldGibson.Net website (under construction). The next biggy I will be putting up before I clean it up and go live is software for making smart clients that run over any IP network and allows pretty easy clustering of servers on the back end to scale up to any level. Check it out if you are into that sort of thing.
|
|
|
|
 |
|
 |
I want to zip a single file rather than a folder this shell api supports this problem
this is haneef
|
|
|
|
 |
|
 |
Yes. When I first started making this it could only zip files. I later added the folder ability. If you look at the code you will see that indeed it is ziping files.
|
|
|
|
 |
|
 |
Hi,
I use your code to zip a folder, but the program hangs in this for loop because the OriginalItemCount doesn't match ZipFileItemCount
//Wait until the ziping is done.
for (; ; )
if (OriginalItemCount == ZipFileItemCount)
{
break;
}
OriginalItemCount is 4196 but ZipFileItemCount is 4207. Any idea? I changed the equal sign to '<' and it exists the loop correctly.
Your code works pretty well. Thanks.
Kelvin
|
|
|
|
 |
|
 |
Hello,
If you look below in the comments you will see that some other coders have had this problem.
Together we came up with various fixes for certain bugs... one of which is the same bug you are seeing. Look for comments by these people...
mickbrooke2
Coach LazyEye
and on the NEXT page in the comments (click next to see them) you will see an exchange between myself and hbahra
In these conversations we end up with a "timeout" so there are no infinite loops and all files get added so that the counts end up matching. As soon as I can I will update this article with a single new download that includes all of these fixes.
Thanks for using my code!
|
|
|
|
 |
|
 |
I'm guessing I shouldn't be doing this but... I'm trying to run on windows 2000 and getting an "Insufficent memory to continue the execution of the program" error.
There is plenty of memory in both boxes I tried it on.
I installed the 2.0 Framework to get this far - anything else I can try?
I'm taking Interop.shell32.dll over from an XP with the .exe.
Everything works great in XP - but my target platform is 2000 - please don't tell me I have to learn c++
|
|
|
|
 |