[C#] How to delete a directory in C#

Byantonhyip

Mar 12, 2019 #c# create directory, #c# create directory and file, #c# create directory from file path, #c# create directory if not exists recursive, #c# create directory path, #c# create directory path if not exist, #c# create directory recursive, #c# create directory tree, #c# create directory with full permissions, #c# create directory with subdirectories, #how to create and delete directory in c#, #how to delete a directory and its contents in c#, #how to delete a directory in c#, #how to delete a file from directory in c#, #how to delete a file in directory using c#, #how to delete a non empty directory in c#, #how to delete a non-empty directory in c#.net, #how to delete a particular file from a directory in c#, #how to delete all file in directory c#, #how to delete all files and subdirectories in a directory c#, #how to delete all files in directory c#, #how to delete all files inside a folder in c#, #how to delete all folders in a directory c#, #how to delete directory and subdirectories in c#, #how to delete directory and subdirectory in c#, #how to delete directory in c#, #how to delete empty folder in c#, #how to delete empty folders in c#, #how to delete entire directory in c#, #how to delete folder and subfolders in c#, #how to delete non empty directory in c#, #how to delete not empty directory in c#, #how to delete the contents of a directory in c#, #how to remove directory in c#, #how to remove file from directory in c#, #how to remove files from directory in c#, #how to remove folder in c#, #how to remove image from folder in c#
Chia sẻ

The Directory.Delete method deletes an empty directory from the specified path permanently. If a directory has subdirectories and/or files, you must delete them before you can delete a directory. If you try to delete a file that is not empty, you will get an error message. The following code snippet deletes the destination file.

string root = @"C:Temp";
// If directory does not exist, don't even try
if (Directory.Exists(root))
{
    Directory.Delete(root);
}

 

ĐĂNG KÝ MUA HÀNG

    Email (*)

    Điện thoại (*)

    Tên sản phẩm/Dịch vụ:


    Chia sẻ
    Xem thêm  [C#] How to Get and Set Current Directory in C#

    Trả lời

    Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *