Q:
C# program to delete an empty and a non-empty directory
belongs to collection: C# file handling (File class) solved programs/examples
C# file handling (File class) solved programs/examples
- C# program to get file creation time
- C# program to write text to a file
- C# program to read text from a file
- C# program to read text from a file and append in another file
- C# program to replace content of one file from other file and create backup file
- C# program to delete a text file
- C# program to set attributes of specified file
- C# program to get attributes of a specified file
- C# program to set new file creation time
- C# program to copy content of one file to another file
- C# program to copy content of one file to another file by overwriting same file name
- C# program to get last access time of file or directory
- C# program to set last access time of file or directory
- C# program to get last access time of file or directory in UTC format
- C# program to set last access time in UTC format of file or directory
- C# program to get last write time of file or directory
- C# program to set last write time of file or directory
- C# program to get last write time in UTC format of file or directory
- C# program to set last write time of file or directory in UTC format
- C# program to move file from one location to another location
- C# program to read all lines of a text file
- C# program to write multiple (all) lines into a text file
- C# program to write byte buffer into a file
- C# program to read byte buffer from a file
- C# program to create directory
- C# program to delete an empty and a non-empty directory
- C# program to check given directory exists or not
- C# program to get complete path of current directory
- C# program to get the list of sub-directories of given directory
- C# program to get computer drive names of given directory
- C# program to search directory in a given directory
- C# program to get root directory of given directory
- C# program to get the list of files from given directory
- C# program to demonstrate the use of CreateSubdirectory method
- C# program to demonstrate the use of Exists property
- C# program to demonstrate the use of FullName property
Program
Output
Note: In above program, we need to remember, when we use "Directory" class, System.IO namespace must be included in the program.
In this program, method is overloaded, to allow or deny recursive deletion.