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#?
Loading
Jignesh TrivediPosted Feb 19, 2014, 11:48 PM
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.
VulpesPosted Feb 19, 2014, 12:11 PM
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.