代码:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 删除文件和文件夹
{
class Program
{
static void Main(string[] args)
{
string path1 = Environment.CurrentDirectory + "\\MyTest";
string path2 = Environment.CurrentDirectory + "\\新建文本文档.txt";
//删除文件夹
if (Directory.Exists(path1))
Directory.Delete(path1, true);
//删除文件
if (File.Exists(path2))
File.Delete(path2);
Console.ReadKey();
}
}
}
end
更多推荐
C# 删除文件和删除文件夹
发布评论