C# Program to Demonstrate the Use of CreateSubdirectory Method
DirectoryInfo class provides different types of methods and properties that are used to perform operations on directories and sub-directories like creating, moving, etc. This class has a CreateSubdirectory() method that is used to create a sub-directory or sub-directories on the given path. Here the given path can be relative to this instance of the DirectoryInfo class.
public System.IO.DirectoryInfo CreateSubdirectory (string spath);
Here, the spath parameter represents the specified path.
Return: It will return the last directory that is specified in the path.
- ArgumentException: This exception will occur when the spath does not specify a valid file path or contains invalid DirectoryInfo characters.
- ArgumentNullException: This exception will occur when the spath is null.
- DirectoryNotFoundException: This exception will occur when the specified spath is invalid, such as being on an unmapped drive.
- IOException: This exception will occur when the subdirectory cannot be created.
- PathTooLongException: This exception will occur when the specified spath, file name, or both exceed the system-defined maximum length.
- SecurityException: This exception will occur when the caller does not have code access permission to create the directory.
- NotSupportedException: This exception will occur when the spath contains a colon character (:) which is not the part of the given drive label (e.g. “E:\”).
IT created successfully
My Personal Notes arrow_drop_up
Please Login to comment...