Advertisement



< Prev
Next >



C# Directory



The Directory class is defined in the System.IO namespace and it provides us static methods to perform the directory manipulation operations such as: Directory class also allows us to get and set the directory specific information such as its creation time, last access time, the last time it was written to.




Some commonly used methods of Directory class



Methods Description
DirectoryInfo CreateDirectory(String path)
This method creates all directories and sub-directories in the specified path, only if they don't already exist.

void Move(String sourceDirectoryName, String destDirectoryName)
This method moves a specified directory to a new location, providing the option to specify a new directory name at the destination.

void Delete(String path)
This method deletes the directory specified by the path.

String[] GetFiles(String path)
This method returns the full names of the files in the directory specified by path.

String[] GetFiles(String path, String pattern)
This method returns the full names of the files with the specified specific pattern in the directory specified by path.

String[] GetDirectories(String path)
This method returns the names of sub-directories in the specified directory..

String GetCurrentDirectory(String path)
This method returns the name of the current working directory.

bool Exists(String path)
This method determines whether the specified directory exists or not.

DateTimeGetCreationTime(String path)
This method returns the creation time of the specified directory or directory.

void SetCreationTime(String path, DateTime time)
This method sets the creation time the specified directory or directory.

DateTime GetLastAccessTime(String path)
This method returns the last access time of the specified directory or directory.

void SetLastAccessTime(String path, DateTime time)
This method sets the last access time of the specified directory or directory was written to.

DateTime GetLastWriteTime(String path)
This method returns the last access time of the specified directory or directory was written to.

void SetLastWriteTime(String path, DateTime time)
This method sets the last time the specified directory or directory was written to.










Please share this article -




< Prev
Next >
< C# File
C# MemoryStream >



Advertisement

Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement



Notifications



Please check our latest addition

C#, PYTHON and DJANGO


Advertisement