我无法删除创建的文件。谁能帮我解决这个问题。
namespace file
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("created");
String Todaysdate = DateTime.Now.ToString("dd-MMM-yyyy");
string path = @"C:\Users\Milan\source\repos\File\File\";
var dirpath = path + @"Reports\AutomationTestReport" + Todaysdate;
Directory.CreateDirectory(dirpath);
var filepath = dirpath + @"\" + "HTMLPage1.html";
File.Create(filepath);
if (File.Exists(filepath))
{
System.IO.File.Delete(filepath);
Console.WriteLine("File deleted");
}
}
}
}