Click here to Skip to main content
16,012,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want to delete the system files which available in the directory only selected files not all.
Posted
Comments
Balamurugan1989 24-Oct-13 4:32am    
What you have tried????

1 solution

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);
}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900