Search files
C#
2
Posts
2
Posters
6
Views
1
Watching
-
How to search for files/folders and adding all the found filenames to a collection. For exemple : Search all "*.url" files on "C:" Thanks
The things you need is located in the namespace System.IO... I would do it like this:
using System.IO;
public void FindFiles (string path)
{
if (Directory.Exists (path))
{
DirectoryInfo thisDir = new DirectoryInfo (path);
FileInfo [] files = thisDir.GetFiles ("*url");
DirectoryInfo [] subDirs = thisDir.GetDirectories ();foreach (FileInfo f in files) { //Do what you should with the files... } foreach (DirectoryInfo d in subDirs) { FindFiles (d.FullName); }
}
}Andreas Philipson