更新时间:2023-01-17 19:57:54
按照以下方式尝试此代码你的要求
try this code as per ur requirements
FileInfo file = new FileInfo(Server.MapPath("foldername\\filename"));
if (file.Exists)
{
File.Delete(Server.MapPath("foldername\\filename"));
}
如果您使用的是单独的文件夹foreach员工。然后尝试这个。
if you are using seperate folder foreach employee. then try this.
private static void EmployeeFiles(string EmployeeFolderPath)
{
try
{
if (Directory.Exists(EmployeeFolderPath))
{
foreach (var item in Directory.GetFiles(EmployeeFolderPath))
{
if (File.Exists(item))
{
File.Delete(item);
}
}
}
}
catch (Exception)
{
throw;
}
}