Create DirectoryInfo class on the specified path. : DirectoryInfo « File Directory « VB.Net






Create DirectoryInfo class on the specified path.

 

Imports System
Imports System.IO

Public Class Test
    Public Shared Sub Main()
        Dim di1 As DirectoryInfo = New DirectoryInfo("c:\MyDir")
        Dim di2 As DirectoryInfo = New DirectoryInfo("c:\MyDir\temp")
        Try
            di1.Create()
            di2.Create()
            di1.Delete()
        Catch e As Exception
            Console.WriteLine("The Delete operation failed as expected.")
        End Try
    End Sub
End Class

   
  








Related examples in the same category

1.DirectoryInfo.Create Creates a directory.
2.DirectoryInfo.CreateSubdirectory
3.DirectoryInfo.Delete deletes this instance of a DirectoryInfo, specifying whether to delete subdirectories and files.
4.DirectoryInfo.Delete deletes this DirectoryInfo if it is empty.
5.DirectoryInfo.EnumerateDirectories Method (String, SearchOption)
6.DirectoryInfo.EnumerateDirectories returns an enumerable collection of directory information in the current directory.
7.DirectoryInfo.Exists Property gets a value indicating whether the directory exists.
8.DirectoryInfo.GetAccessControl
9.DirectoryInfo.GetDirectories returns an array of directories in the current DirectoryInfo matching the given search criteria.
10.DirectoryInfo.GetDirectories (String, SearchOption)
11.DirectoryInfo.GetDirectories returns the subdirectories of the current directory.
12.DirectoryInfo.GetFiles returns a file list from the current directory matching the given search pattern.
13.DirectoryInfo.GetFiles returns a file list from the current directory.
14.DirectoryInfo.MoveTo moves a DirectoryInfo instance and its contents to a new path.
15.DirectoryInfo.Name Property gets the name of this DirectoryInfo instance.
16.DirectoryInfo.Parent Property gets the parent directory of a specified subdirectory.
17.DirectoryInfo.Root Property gets the root portion of a path.
18.DirectoryInfo Class Exposes instance methods for creating, moving, and enumerating through directories and subdirectories
19.Copy a directory with DirectoryInfo
20.Create and delete directory with DirectoryInfo
21.FileSystemInfo Class provides the base class for both FileInfo and DirectoryInfo objects.