Re: Getting all files in Dir and Subdirs



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

.



Relevant Pages

  • Re: folder permission question
    ... Best regards, ... Jim Graue ... I'm having trouble remembering the way to set permissions on a folder ... into others' subfolders and/or files. ...
    (microsoft.public.windows.server.general)
  • Re: NTFS and Shares ritghts vs. Netware Rights
    ... Have I on the root folder to set the "List folder" right and stop the ... inheritance on those subfolders I do not want people to see? ... Regards ... >> access the share but see no subfolfer even if NTFS rights are set for some ...
    (microsoft.public.win2000.security)
  • Re: File/directory permissions
    ... > the requirement that the users not be able to create new subfolders or ... > directly under a project's folder. ... Thanks, Roger. ... Regards ...
    (microsoft.public.win2000.security)
  • find files by date
    ... i'm trying to gnu-find all files in a specific folder (and its ... subfolders), which were created AFTER a specific date, e.g. all files ... Regards, ...
    (comp.unix.shell)
  • RE: Disappearing Network Share Subfolders
    ... Thank you for posting to the SBS Newsgroup. ... I understand that some of your Windows XP SP2 clients cannot view the ... subfolders in share folders on SBS 2K Server. ... Does the problematic share folder locate at NTFS or FAT32 disk? ...
    (microsoft.public.windows.server.sbs)