how can I delete the text file that I just craeted in C#
Let;s say I have a text file test.txt test.zip in c:\exporter
there could be moren than one file and the name of file can be different
and i would like to remove files from this folder. how can i do this using C#?
Delete files from folder
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Feb 19, 2014, 7:11 AM EST
If you want to delete multiple files created on a certain date or within a certain time, then you'd need to filter the files in the folder to start with and then delete each of them in turn.
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 19, 2014, 6:48 PM EST
hi,
try
var rootFolder = new System.IO.DirectoryInfo(@"C:\exporter");
foreach (var file in rootFolder.GetFiles("*", System.IO.SearchOption.AllDirectories))
{
if (System.IO.File.Exists(file.FullName))
{
file.Delete();
}
}
hope this will help you.