我需要删除特定employeeid的文件。 [英] i need to delete the files of particular employeeid.
本文介绍了我需要删除特定employeeid的文件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
FileInfo file = new FileInfo(Session["Path"].ToString());
if (file.Exists)
{
file.Delete();
}
使用此代码我只能删除一个文件中的文件。我需要删除特定employeeid的文件。
by using this code i m able to delete only one file from the document. i need to delete the files of particular employeeid.
example:
101_resume.pdf,
102_voter.pdf,
i m able to delete the first. how to go with second also. at a time they need to delete
推荐答案
按照以下方式尝试此代码你的要求
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;
}
}
这篇关于我需要删除特定employeeid的文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文