Re: Getting all files in Dir and Subdirs
- From: augustesen@xxxxxxxxxxxxxxxxx
- Date: 6 Oct 2005 04:43:07 -0700
Hi
This code gives you all the files and subdirs in a given folder
public void ProcessDirectory(string targetDirectory)
{
// Handels the files found in the main folder
string [] fileEntries = Directory.GetFiles(targetDirectory);
foreach(string fileName in fileEntries)
{
ProcessFile(fileName); //This function does what ever you want
to do with the files
}
// Finding the sub directories in the folder
string [] subdirectoryEntries =
Directory.GetDirectories(targetDirectory);
// For each subfolder this function is called again
foreach(string subdirectory in subdirectoryEntries)
{
AllDirNames.Add(subdirectory); //Add the Dir location to a
Global ArrayList
ProcessDirectory(subdirectory); //Calls this function againg
with the subdir as parmeter
}
}
Regards
Søren Augustesen
augustesen@xxxxxxxxxxxxxxxxx skrev:
> Hi
>
> I am looking for a way to get all the files in a specific folder and
> its subfolders (and the subfolders subfolders and so on).
>
> Is there an easy way of doing this? Or do I have to go through every
> single folder and subfolder?
>
> Regards
> Søren Augustesen
.
- References:
- Getting all files in Dir and Subdirs
- From: augustesen
- Getting all files in Dir and Subdirs
- Prev by Date: Re: PDA connecting to device via serial port
- Next by Date: Looking for a C# programmable Gird control that supports SqlCeResultSets, Advanced binding (can display tabular data from multiple tables on the same row), CF 2.0
- Previous by thread: Re: Getting all files in Dir and Subdirs
- Next by thread: Re: How to find a service name of IR Device
- Index(es):
Relevant Pages
|