Advertisement
calfred2808

create directory

Dec 4th, 2016
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.83 KB | None | 0 0
  1.   Public Shared Sub Main()
  2.         ' Specify the directory you want to manipulate.
  3.         Dim path As String = "c:\MyDir"
  4.  
  5.         Try
  6.             ' Determine whether the directory exists.
  7.             If Directory.Exists(path) Then
  8.                 Console.WriteLine("That path exists already.")
  9.                 Return
  10.             End If
  11.  
  12.             ' Try to create the directory.
  13.             Dim di As DirectoryInfo = Directory.CreateDirectory(path)
  14.             Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(path))
  15.  
  16.             ' Delete the directory.
  17.             di.Delete()
  18.             Console.WriteLine("The directory was deleted successfully.")
  19.  
  20.         Catch e As Exception
  21.             Console.WriteLine("The process failed: {0}.", e.ToString())
  22.         End Try
  23.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement