2014-08-29 66 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);