How to get the current path using VBScript

To get the current path using VBScript you can use the snippet below.

Samples

VBScript Sample

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

Related links:

Please rate this snippet

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:

Please rate this snippet

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.

Please rate this snippet

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>
    

    Please rate this snippet

    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
    

    Please rate this snippet

    How to copy a Folder/Directory recursive in C# and VB.NET

    How to copy a Folder/Directory recursive in C# and VB.NET.

    Sample C#

    public void RecursiveFolderCopy(string sourceDirectory, string destinationDirectory, bool recursive)
    {
    	var dir = new DirectoryInfo(sourceDirectory);
    	var dirs = dir.GetDirectories();
    
    	if (!dir.Exists)
    	{
    		throw new DirectoryNotFoundException(
    			String.Format("Source directory {0} does not exist!",
    				sourceDirectory));
    	}
    
    	if (!Directory.Exists(destinationDirectory))
    	{
    		Directory.CreateDirectory(destinationDirectory);
    	}
    
    	var files = dir.GetFiles();
    	foreach (var file in files)
    	{
    		var temppath = Path.Combine(destinationDirectory, file.Name);
    		file.CopyTo(temppath, false);
    	}
    
    	if (!recursive)
    	{
    		return;
    	}
    	foreach (var subdir in dirs)
    	{
    		var temppath = Path.Combine(destinationDirectory, subdir.Name);
    		RecursiveFolderCopy(subdir.FullName, temppath, recursive);
    	}
    }
    

    Sample VB.NET

    Public Sub RecursiveFolderCopy(ByVal sourceDirectory As String, ByVal destinationDirectory As String, ByVal recursive As Boolean)
            Dim dir As var = New DirectoryInfo(sourceDirectory)
            Dim dirs As var = dir.GetDirectories
            If Not dir.Exists Then
                Throw New DirectoryNotFoundException(String.Format("Source directory {0} does not exist!", sourceDirectory))
            End If
            If Not Directory.Exists(destinationDirectory) Then
                Directory.CreateDirectory(destinationDirectory)
            End If
            Dim files As var = dir.GetFiles
            For Each file As var In files
                Dim temppath As var = Path.Combine(destinationDirectory, file.Name)
                file.CopyTo(temppath, false)
            Next
            If Not recursive Then
                Return
            End If
            For Each subdir As var In dirs
                Dim temppath As var = Path.Combine(destinationDirectory, subdir.Name)
                RecursiveFolderCopy(subdir.FullName, temppath, recursive)
            Next
        End Sub
    

    Please rate this snippet