删除项目中可用的系统文件 [英] Deleting the system file which available in the project

查看:74
本文介绍了删除项目中可用的系统文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想要删除目录中只有选定文件不可用的系统文件。

Hi,
I want to delete the system files which available in the directory only selected files not all.

推荐答案

按钮或菜单你需要写两行。

string msg = null;

ClearFolder(msg);

需要创建方法。

private void ClearFolder(string FolderName)

{

string [] delete_files_2DData = null;

string [ ] delete_files_Data = null;

string [] datafile = null;

尝试

{

delete_files_2DData =目录。 GetFiles(Environment.CurrentDirectory +\\DB\\2DData \\+ Global.CreatedProjectName +\\);

string file = System.IO。 Path.GetDirectoryName(Environment.CurrentDirectory +\\DB\\2DData \\+ Global.CreatedProjectName +\\);

datafile = Directory.GetFiles (Environment.Curren tDirectory +\\Data\\);

string prf =+ Global.CreatedProjectName;

string rname =+Run + Global.RunOpend;

foreach(数据文件中的字符串data_file)

{

string [] datafilpath = data_file.Split('\\\ \\');

string [] finalpath = datafilpath.Last()。分割('_');

if(finalpath.Contains(prf))

{

File.Delete(data_file);

}

}

}

catch(例外情况)

{

MessageBox.Show(ex.Message);

}

}
inside the button or menu u need to write the two lines.
string msg = null;
ClearFolder(msg);
need to create the method.
private void ClearFolder(string FolderName)
{
string[] delete_files_2DData = null;
string[] delete_files_Data = null;
string[] datafile = null;
try
{
delete_files_2DData = Directory.GetFiles(Environment.CurrentDirectory + "\\DB\\2DData\\" + Global.CreatedProjectName + "\\");
string file = System.IO.Path.GetDirectoryName(Environment.CurrentDirectory + "\\DB\\2DData\\" + Global.CreatedProjectName + "\\");
datafile = Directory.GetFiles(Environment.CurrentDirectory + "\\Data\\");
string prf = "" + Global.CreatedProjectName;
string rname = "" + "Run" + Global.RunOpend;
foreach (string data_file in datafile)
{
string[] datafilpath = data_file.Split('\\');
string[] finalpath = datafilpath.Last().Split('_');
if (finalpath.Contains(prf))
{
File.Delete(data_file);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}


这篇关于删除项目中可用的系统文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆