[RESOLVED] Search in the folder and sub folders
Hai
i want to search for files in Application folder and its sub folder.
When i am trying to search from Application.StartupPath it is searching in Debug folder only.
i want to verify the files availability in all folders and sub folders and should confirm the existense of the file.
Please help me in this regard
Thanks and Regards
Vinay Kumar
Re: Search in the folder and sub folders
Check out the DirectoryInfo class.
Re: Search in the folder and sub folders
Please specify your version when posting. It's as simple as one click.
If you're using .NET 2.0 then IO.Directory.GetFiles and IO.DirectoryInfo.GetFiles both offer an option to search subfolders. If you're using an older version then you can write your own recursive mthod:
Code:
private void GetFiles(string folder)
{
foreach (string file in Directory.GetFiles(folder))
{
MessageBox.Show(file);
}
foreach (string subfolder in Directory.GetDirectories(folder))
{
this.GetFiles(subfolder);
}
}
Re: Search in the folder and sub folders
Thank you and sorry for not mentioning version
i am using c# 2.0 .i got the solution
Thanks for the guide
Vinay Kumar