I have a method that will iterate through a folder and all of its subfolders and get a list of the file paths. However, I could only figure out how to create it and add the
Try this
class Program
{
static void Main(string[] args)
{
getfiles get = new getfiles();
List files = get.GetAllFiles(@"D:\Rishi");
foreach(string f in files)
{
Console.WriteLine(f);
}
Console.Read();
}
}
class getfiles
{
public List GetAllFiles(string sDirt)
{
List files = new List();
try
{
foreach (string file in Directory.GetFiles(sDirt))
{
files.Add(file);
}
foreach (string fl in Directory.GetDirectories(sDirt))
{
files.AddRange(GetAllFiles(fl));
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return files;
}
}