# Add Directory Method

 Jubalation Jul 5, 2011 at 2:10 PM I am having problems with the AddDirectory Method.  I downloaded the library and looked through the reference material, the FAQs, and some of the discussions but I haven't found an exact solution to my problem.  When I use the overloaded AddDirectory method the files are added to the zip file without the root directory (directoryPathInArchive) I specify.  Has anyone else had this problem or know of a possible solution? I am using VB .NET with a 2.0 framework The code I use is  Try   Dim baseFolder as String = "D:\Users\SomeFolder"   Using zip As ZipFile = New ZipFile   zip.AddDirectory(baseFolder, System.IO.Path.GetFileName(baseFolder))   zip.Save(baseFolder & ".zip")   End Using  Catch ex As Exception   Msg.Box("Unable to zip files(s)") End Try I've even tried this, just to test if a directory was being written to the zip file Try   Using zip As ZipFile = New ZipFile   zip.AddDirectoryByName("SomeFolder")   zip.Save("SomeFolder.zip")   End Using  Catch ex As Exception   Msg.Box("Unable to zip files(s)") End Try Cheeso Coordinator Jul 5, 2011 at 7:29 PM I just tried your exact code here - changed only the path - and it seems to work correctly for me. You said "the files are added without the root directory you specify".   What does that mean exactly?  When I run it on a directory, c:\foo\bar\bam , and that directory contains A.txt, B.txt, and C.txt, in the resulting zip file I get  bam\A.txt bam\B.txt and bam\C.txt.  Is this not similar to what you see? Can you give me a list of the files in the directory, and a list of files in the zip file after you run the code you have above?  You can generate the former list with dir /w (From a cmd.exe prompt) and you can generate the latter list using unzip.exe -l zipfile.zip  - unzip.exe is a tool included in the DotNetZip tools download.  Also I don't know what you mean by "I've even tried this..."  you said you tried it but you didn't report the results you saw, or why you think those results are also wrong. Jubalation Jul 6, 2011 at 12:25 AM Cheeso, I went to generate my list of files using the unzip commad and it seems as if the "directoryPathInArchive" does not physically appear in the WinZip window (the window that appears after you double click a zip file to be opened with WinZip).  In the WInZip window, the files are listed as "fileA, fileB, fileC."  After I unzip the file the hierachy is displayed correctly as "SomeFolder\fileA, SomeFolder\fileB. SomeFolder\fileC."  Thank you for your help Cheeso Coordinator Jul 6, 2011 at 2:27 PM ah, ok.  So there's no problem then.  Good deal.