 |
|
 |
Hi,
i have written windows service this service will Extart ZIP file and place into one folde. i have impletend using below code
Shell32.Shell sc = new Shell32.Shell();
Shell32.Folder SrcFlder = sc.NameSpace(sourcePath);
Shell32.Folder DestFlder = sc.NameSpace(destination);
Shell32.FolderItems items = SrcFlder.Items();
DestFlder.CopyHere(items, 20);
System.Threading.Thread.Sleep(1000);
in my Service but it is not working.
If i run this code in Widows application it is working fine.
Please can you help me out in this issue.
|
|
|
|
 |
|
 |
Shell commands are not normally accessible to Services. The user the service runs under must have all the desktop access that a regular user would (which is why it works for you when you run a desktop app as a normal user). You can try messing around with the user account the service runs under and see if you can get it to work.
|
|
|
|
 |
|
 |
This doesn't work with Net v4.
The demo project crashes.
|
|
|
|
 |
|
 |
A license is required to use the internal zip API that is included by Microsoft for Zip Folders support. The Inner Media, Inc. owns the copyright and controls the licensing.
|
|
|
|
 |
|
 |
For those want to use in .NET4 the interop dll doesn't work generated from win7.
Use reflection to create an object and cast to the interface:
Type shellType = Type.GetTypeFromProgID("Shell.Application");
object oShell = Activator.CreateInstance(shellType);
Shell32.IShellDispatch5 sc = (Shell32.IShellDispatch5)oShell;
//then use sc.... as normal.
|
|
|
|
 |
|
 |
I tried many third party components for unziping. Which has thrown many errors
|
|
|
|
 |
|
 |
Is Interop.Shell32.dll compatible for 32 and 64 bit machines. If no, where to get Interop.Shell32.dll for 64 bit?
|
|
|
|
 |
|
 |
very nice explanation and solved my problem
|
|
|
|
 |
|
 |
Thanks for your code. It is working on my local machine (XP) but it is not working on windows server 2008. The same Code works fine if i try in a sample application which is not a windows service.
Any idea?
|
|
|
|
 |
|
 |
Looks like a 32bit/64bit issue, but I am not sure.
I faced the same problem with win7 64-bit...
|
|
|
|
 |
|
 |
Hi,
I am very new to C#. I am looking around how to zip and unzip the files and folders. I am sure your code will help me alot. Your code was converted to VS2008, COM was added. When I run it I got this error. Win32Exception was unhandled. the program stop at the line "System.Diagnostics.Process p = System.Diagnostics.Process.Start(i);". Any idea on that? Thank Zaw
|
|
|
|
 |
|
 |
Hello,
Hello, I like your way of doing unzip with Shell32. I followed it however, I am getting " The system cannot find the file specified" error at the shell.NameSpace(sourceZipFile). I have the Shell32.dll reference. I also have the Interop.shell32.dll in my both bin/debug and obj/debug. Is there way that you can shed some lights on this? I know many people on the internet made what you suggested work. some how it failed on me, my colleague got the same problem too. I think it is the environment that cause the problem, is there any place that I need to check for my environment?
-Rick
|
|
|
|
 |
|
 |
If you look through the rest of the posts below you will see other people that had similar issues and how they were resolved.
There could be many reasons why you are getting the error you are getting.
|
|
|
|
 |
|
 |
when i debug this sample i got an error like "Object reference not set to an instance of an object." highlight section on the
FolderItems items = SrcFlder.Items();
code.
whats that and what should i do to fix that problem please help
|
|
|
|
 |
|
 |
That probably means that SrcFlder is equal to NULL... so the path provided when getting SrcFlder is probably incorrect.
|
|
|
|
 |
|
 |
wow thanks for super fast reply
but im sure it is not null because i put there a zip(compressed) file.
also i have another question that the code for click event handler next to shell method, what exactly am i going to text to txtSource and txtDestination textboxes?
thanks for your help
|
|
|
|
 |
|
 |
If I were you I would put a break on that line of code in Visual Studio and see for sure if it is NULL... it is the only object in that line of code and the error you described always means that a variable that is supposed to hold a live object is infact NULL.
It has been a while since I wrote this code so I might be off a little here, but those textboxes are probably supposed to hold the paths to the source zip file and the destination zip file.
|
|
|
|
 |
|
 |
hmm but although i wrote the zip file path to txtSource and the destination path where zipped file will be extracted to , i didnt worked and this code is vital for my project
my zip file pathSource="c:/Users/secretyavuz/Desktop/hadi/oglenDeneme.zip";
my dest file path, it should be extracted to this specific folder : pathDestination="c:/Users/secretyavuz/Desktop/hadi";
and also there should be no UI during compress.
thanks for your great helps..
|
|
|
|
 |
|
 |
Your slashes are pointing in the wrong direction... it should be:
c:\Users\secretyavuz\desktop\hadi\oglenDeneme.zip
Other than this I dont know what the problem might be. If you read through the others that have posted on this article you should see issues people were having and what resolved them. This might help you get your project completed.
|
|
|
|
 |
|
 |
Is there a way to unzip a file which does not have a specific .zip extension ? I've tried your code, and it works if my file as a .zip extension, but doesn't if it's something else, like ".z00" ....
Thanks for sharing your code by the way, it's appreciated
|
|
|
|
 |
|
 |
My guess is that the answer in general is no. This is because my code relys on the Windows zipping functionality which uses extensions to recognize zip "folders"... however you could modify my code so it temporarily changes the extension to .zip and then back again when done.
|
|
|
|
 |
|
 |
Yeah, that's pretty much what I thought too... thanks for the quick answer
|
|
|
|
 |
|
 |
Hello:
I'm trying to understand why the following call results in a null value:
Shell32.Folder DestFlder = sc.NameSpace(dest);
where dest = "C:\Documents and Settings\andrea.washington\My Documents\Visual Studio 2008\Projects\HorizonReportResend\bin\Debug\horizonResend"
Yes the folder does exist and yes I have put quotation marks around the path. I tried using the sample app thinking it was my code but the same thing happens using the sample app. I have tried putting the horizonResend folder in different spots under C:\Documents and Settings but still get a file not found message. The call works fine if the horizonResend folder is on the root of C (C:\horizonResend).
Any ideas??
Thanks
|
|
|
|
 |
|
 |
I created the exact path you mentioned and used this code which did not result in a null... see if this works...
Shell32.ShellClass sc = new Shell32.ShellClass(); Shell32.Folder SrcFlder = sc.NameSpace(@"C:\Documents and Settings\andrea.washington\My Documents\Visual Studio 2008\Projects\HorizonReportResend\bin\Debug\horizonResend");
|
|
|
|
 |
|
 |
Any tips on debugging this when something goes wrong? I wrapped this up in an assembly, and am using this in a web application to zip and stream files to the user. Everything works great on my dev machine, however when I deploy it to a test machine, it creates the ZIP folder, but never adds any files to it, and finally just times out.
I've verified the file paths are correct, the IIS user it runs under has read/write permissions on the folder, and I'm pretty much stuck at this point trying to figure out what I'm doing wrong.
Any help would be appreciated.
|
|
|
|
 |