How to extract a password protected zip file using DotNetZip in C# and VB.NET

To extract (unzip) a password protected zip file using the Ionic DotNetZip Library, you can use the snippet below.

Samples

[tab name=”C# Sample”]

[/tab]
[tab name=”VB.NET Sample”]

[/tab]

[end_tabset]

If you have any questions or suggestions feel free to rate this snippet, post a comment or Contact Us via Email.

Related links:

How to delete .svn files and folders using Windows Batch Script

to delete .svn files and folders using Windows Batch Script you can use the following snippet.

Sample Windows Batch Script

FOR /R "C:\Users\CodeSnippets.Fesslersoft.de\Documents\Visual Studio 2013\Projects\ConsoleApplication" %%X IN (.svn) DO (RD /S /Q "%%X" 2>nul)

Replace C:\Users\CodeSnippets.Fesslersoft.de\Documents\Visual Studio 2013\Projects\ConsoleApplication with your Solution’s Path.

How to load project references from a sub directory in C# and VB.NET

To load project references from a sub directory in C# and VB.NET you simply need to add the element to your app.config file.

  • assemblyBinding: Contains information about assembly version redirection and the locations of assemblies.
  • configuration: The root element in every configuration file used by the common language runtime and .NET Framework applications.
  • runtime: Contains information about assembly binding and garbage collection.
  • Sample XML

    <configuration>
       <runtime>
          <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
             <probing privatePath="bin;bin2\subbin;bin3"/>
          </assemblyBinding>
       </runtime>
    </configuration>
    

    How to check if Directory has Files in C# and VB.NET

    To check if Directory has Files in C# and VB.NET you can use the following snippet.

    Sample C#

    public static bool HasFilesInFolder(DirectoryInfo folder)
    {
    	return folder.GetFiles("*.*").Any();
    }
    

    Sample VB.NET

    Public Shared Function HasFilesInFolder(folder As DirectoryInfo) As Boolean
    	Return folder.GetFiles("*.*").Any()
    End Function
    

    How to set the start location of FolderBrowserDialog in C# and VB.NET

    To set the start location of FolderBrowserDialog in C# and VB.NET you can use the following snippet.
    To do so, simply set the SelectedPath Value to the path you want.

    Sample C#

    MyFolderBrowserDialog.SelectedPath = @"C:\Test";
    

    Sample VB.NET

    MyFolderBrowserDialog.SelectedPath = "C:\Test"