ZIP File Creation Using C# and Shell32.dll RRS feed

  • Question

  • Hello,

    I'm trying to create a zip file in C# using the Windows Shell API (Shell32.dll) with essentially the same code as in the thread titled ("Problem creating Zip File using Shell32.dll" by user "Jeyaraj" - see provided link below)


    The code works completely fine on one workstation, but fails in another.  I receive a "File Not Found Exception" on the call

    Shell32.Folder DestFlder = sc.NameSpace(TempPath + "\\" + ZipFileName);

    I can verify visually that an empty zip archive is available in the specified target destination directory, but the above command consistently fails.

    I am running Windows XP Pro SP2 with Visual Studio 2005 and .NET Frameworks 1.1 and 2.0 installed.  However, the above code works okay on my other workstation with XP Pro SP2 with Visual Studio 2003 and .NET Framework 1.1.  I've also verified that I have exactly the same version of the Shell32.dll on both machines.

    Any ideas on why I'm getting this error on one machine but not the other?

    Thanks for any and all suggestions!


    Monday, December 4, 2006 7:23 PM


All replies

  • Hi,

    I know this doesn't answer your question but have you considered using SharpZipLib?

    It's easy to use and learn.


    Monday, December 4, 2006 10:26 PM
  • Thanks for the suggestion Charles.  Yes, I did locate that library before, but I've been trying to stay away from open source tools and stick to standard Microsoft technology.

    Monday, December 4, 2006 10:32 PM
  • What's the value of TempPath on the PC that fails?
    Tuesday, December 5, 2006 2:02 PM
  • Hi,

    TempPath has the value "C:\\Compression\\CompressedOutput".  When concatenated with the zip file name, the full command being executed is:


    This call returns a value of null to the Destination Folder, indicating the path does not exist, yet the previous code has clearly created this empty zip archive in that location.


    Tuesday, December 5, 2006 6:28 PM
  • I am doing the same thing with one thing different.  I would like to use the zip file as a container without compressing the files.

    Have you noticed how to specify the compression method?

    Wednesday, December 13, 2006 6:59 PM
  • I'm having the same problem.  I know this thread is old, but does anyone have the solution?
    Monday, March 17, 2008 8:08 PM
  • Same problem, meaning, you don't want compression?

    Have you looked at DotNetZip



    (It's open source)


    • Proposed as answer by cheeso Saturday, October 4, 2008 12:41 AM
    Saturday, April 26, 2008 12:46 AM
  • I suggest this .NET ZIP Component . It does more than your needs.
    Saturday, October 31, 2009 7:58 AM
  • One component that perfectly does these works for you is Ultimate Zip Component . It's good.
    Sunday, March 14, 2010 10:36 PM
  • If you want to stick on "standard Microsoft technology", you can try the System.IO.Packaging.ZipPackage (part of .NET Framework 3.0 or higher) class for some zipping issues.
    However, it is primarily intended for working with Open Packages (used e.g. in XPS or in OpenXML format for MS Office 2007 documents) and some things are hard to do using this library.

    If you are refusing open source components just because of their limited support or guarantee, you can try some commercial component, e.g. our Rebex ZIP. It does not depend on any other library, and it consists of 100% managed code just over .NET Framework (2.0 or higher).

    Thursday, September 16, 2010 9:19 AM