如何清空文件夹里面的所有文件和文件夹
程序员文章站
2023-12-20 09:23:28
复制代码 代码如下:private void deletefileordic(system.io.directoryinfo path) ...
复制代码 代码如下:
private void deletefileordic(system.io.directoryinfo path)
{
try
{
foreach (system.io.directoryinfo d in path.getdirectories())
{
d.delete(true);
}
foreach (system.io.fileinfo f in path.getfiles())
{
f.delete();
}
}
catch (exception ex)
{
}
}