18 August 2012

Delete Particular File Format from Folder using C#.net

This is very easy .User can delete file using File.Delete Keyword .this method is using for deleting file(s) from particular  folder with specified format.
public void DeleteFiles(String Path, String fileType) {
string[] files = Directory.GetFiles(Path, fileType);
foreach (string file in files)
{
File.Delete(file);
}
}
DeleteFiles("Specify Path","Particular File Type");
eg:
if you want to delete a bmp file in a NewFolder in the E Disk.
DeleteFiles("E:\\NewFolder\\","*.bmp");

No comments: