C#中如何用递归方法删除一个文件夹中所有内容??

来源:百度知道 编辑:UC知道 时间:2024/06/22 15:30:10
我也知道可以用true删,但是现在就要递归删,擦。。。
谁给我先写个删除一个文件夹的完整程序我看看呗。。。。

先把文件去除所有文件的只读属性,然后删了;然后如果有文件夹就递归,没有就return,return之前把当前目录页删了。

递归删。。毛病

参照 递归计算文件夹的大小

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace FileSizeClass
{
public class FileSizeClass
{
string FilePath = ""; //文件或者文件路径
public double GetSize(string path)
{
double size = 0;
if (path == null || path.Trim() == "" || path.Length == 0)
{
return size;
}
FilePath = path;
try
{
//判断求大小的是文件还是文件大小
if (System.IO.File.Exists(FilePath))
{
size = GetSingeFileSize(FilePath);
}
}
catch (Exception err)
{

}