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"

Please rate this snippet

How to create a folder in C# and VB.NET

To create a folder in C# and VB.NET you can use the following snippet.

Sample C#

try
{
	const string path = @"C:\Users\Codesnippets\Desktop\Testfolder\Test1\Test2";
	Directory.CreateDirectory(path);
}
catch (Exception ex)
{
	//handle the exception your way
}

Sample VB.NET

Try
	Const  path As String = "C:\Users\Codesnippets\Desktop\Testfolder\Test1\Test2"
	Directory.CreateDirectory(path)
Catch ex As Exception
        'handle the exception your way
End Try

Please rate this snippet

How to delete a file or folder in Powershell

To delete a file or Folder in Powershell you can use the following snippet.

Sample Powershell

if you want to delete a file use

remove-item -path "C:\Users\Codesnippets\Desktop\Test.xml" -force -recurse

if you want to delete a folder use

remove-item -path "C:\Users\Codesnippets\Desktop\Folder1" -force -recurse

for more informations see Using the Remove-Item Cmdlet

Please rate this snippet

How to check if file or folder exists in Powershell

To check if file or folder exists in Powershell you can use the following snippet.

Sample Powershell

for files use it like this

if(test-path "C:\Users\Codesnippets\Desktop\Test.xml") 
{ 
	echo "exists!" 
} 
else 
{ 
	echo "not exists!" 
}

for folders/directories use it like this

if(test-path "C:\Users\Codesnippets\Desktop") 
{ 
	echo "exists!" 
} 
else 
{ 
	echo "not exists!" 
}

Please rate this snippet