Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to delete all files in a directory c#

System.IO.DirectoryInfo di = new DirectoryInfo("YourPath");

foreach (FileInfo file in di.GetFiles())
{
    file.Delete(); 
}
foreach (DirectoryInfo dir in di.GetDirectories())
{
    dir.Delete(true); 
}
Comment

How to delete folder with files on c#

Directory.Delete(@"folderPath", true);
Comment

delete all dir content c#

 new System.IO.DirectoryInfo(@"C:Temp").Delete(true);

 //Or

 System.IO.Directory.Delete(@"C:Temp", true);
Comment

C# delete folder with all contents

System.IO.Directory.Delete("C:TempTest", True)
Comment

c# how to delete all files in directory

		/// <summary>
        /// Delete all files inside a directory
        /// </summary>
        /// <param name="filePath">Directory Path</param>
		Using System.IO;
        public static void DeleteFiles(string filePath)
        {
            if (!Directory.Exists(filePath))
            {
                throw new Exception("Directory not exist");
            }

            string[] existingFiles = Directory.GetFiles(filePath);
            if (existingFiles.Length > 0)
            {
                foreach (var item in existingFiles)
                {
                    File.Delete(item);
                }
            }
        }
Comment

PREVIOUS NEXT
Code Example
Csharp :: convert string into float C# 
Csharp :: request a pricipal permission 
Csharp :: c# split quotation 
Csharp :: Create a button in unity to show ad 
Csharp :: stop playing audiosource 
Csharp :: Block iFrames | How to Stop Your Website From Being iFramed 
Csharp :: structure in c sharp with example 
Csharp :: unity how to make gamemanager instance 
Csharp :: c# get file author 
Csharp :: c# datagridview multiple row selection without control 
Csharp :: trhow exception if is null c# 
Csharp :: c# builder pattern fluent example 
Csharp :: 405 - HTTP verb used to access this page is not allowed 
Csharp :: c# convert securestring to string 
Csharp :: net user add ne user windows 10 
Csharp :: c# list contains null 
Csharp :: C# Change color 
Csharp :: oncollisionenter2d 
Csharp :: unity how to check index of enum 
Csharp :: convert list of string to dictionary 
Csharp :: list to ilist c# 
Csharp :: c# textbox only numbers 
Csharp :: ssml 
Csharp :: Triangle perimeter 
Csharp :: sqlite execute 
Csharp :: calculate string length vs pixels c# 
Csharp :: dataannotations for currency in c# 
Csharp :: c# null accessor 
Csharp :: fix autofill issue asp.net mvc 
Csharp :: c# delay 1 second 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =