What about:
string[] filenames = Directory.GetFiles(path, "*",
SearchOption.AllDirectories);
Then loop through each filename and delete it. In this case I have the
SearchOption for all directory or just for the top directory.
foreach(string fileName in Directory.GetFiles(targetDirectory)
{
File.Delete(fileName);
}
Yes I did something like that.
The paths are correct but the files are not deleted.
And I don't get any error which is strange.
// Delete
public void Delete(String path, String pattern, SearchOption
option) {
String[] files = Directory.GetFiles(path, pattern, option);
foreach (String f in files)
File.Delete(new Uri(f).LocalPath);
} // Delete
And I also tried simply with:
File.Delete(f);
And then I use it as follows:
fileService.Delete(controller.Server.MapPath("~/Data"), "*",
SearchOption.AllDirectories);
I also tried with controller.Server.MapPath("~/Data/") but the files
are not deleted either.
The paths I get are something as follows:
"C:\\Users\\Miguel\\Projects\\Std\\Solution\\Std\\Data\\Assets.xml"
And it is correct.
Any idea why the files are not being deleted?
Thanks,
Miguel