c# directory delete code example
Example 1: 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);
}
Example 2: how to delete from a list c#
var resultList = new List<int>();
resultList.Add(1);
resultList.Add(2);
resultList.Add(3);
resultlist.RemoveAt(0);
var itemToRemove = resultlist.Single(r => r.Id == 2);
resultList.Remove(itemToRemove);