2014-08-29 65 views
-4

我想通過這樣來刪除目錄中的所有文件:System.IO.File.Delete無效字符

System.IO.File.Delete(directoriodestino_imagenes + @"\*.*"); 

其中,directoriodestino_imagenes = "C:\\dcm\\patients\\NAME_LASTNAME\\DCM\\"

而且我得到這個:

{ 「路徑中具有非法字符。」}

任何提示我可能做錯了什麼?

+4

從ONLINE REFERENCE引用:'path:要刪除的文件的名稱。通配符不支持.' – 2014-08-29 00:05:16

回答

1

實際上可以刪除文件夾中的文件。這是我如何做到的。

string directory = @"C:\File Downloader\DownloadedFile\"; 
string[] file = Directory.GetFiles(directory); // get all files in the folder. 
foreach (string fileName in file) 
File.Delete(fileName);