retrieving files of filesystem

  • Thread starter Thread starter Yves
  • Start date Start date
Y

Yves

Hello,

I have a little question.
I want to make a small app that counts all the files located in a specific
directory (chosen via a FolderBrowserDialog by a user). The question is: is
there a method (of something else) that can retrieve all the files (in that
specific directory) and subdirectories (and in possible subdirectories of
the subdirectories). So I mean every single file starting with the given
folder and not only the files in the mainfolder (NOT dir.getfiles())
Or do I have to create my own method with arrays or collections...

Thank you,

Yves
 
You can create a recursive method.. in it loop through all objects in the
folder, if of type file, count it, if of type folder, call the method again
passing the new folder name. Haven;t done it in .Net, but ahve in VB6 using
FileSystemObject so should be very similar.
 
* "Yves said:
I want to make a small app that counts all the files located in a specific
directory (chosen via a FolderBrowserDialog by a user). The question is: is
there a method (of something else) that can retrieve all the files (in that
specific directory) and subdirectories (and in possible subdirectories of
the subdirectories). So I mean every single file starting with the given
folder and not only the files in the mainfolder (NOT dir.getfiles())
Or do I have to create my own method with arrays or collections...

You will have to recursively enumerate the files and count them:

<URL:http://dotnet.mvps.org/dotnet/samples/filesystem/downloads/RecursiveFileScan.zip>
 
Hi Yves,

Using the directoryinfo that it easy, this is the same as creating your own
file dialog box with that.
http://msdn.microsoft.com/library/d...directoryinfoclassgetfilesysteminfostopic.asp

However what methode you use you should have to do code for it.
It does not appears in your program when you do not get the info from the
seperates directory.

Although you can use that dump methode using a dos command with redirection
of the output. However that I will never advice.

I hope this helps?

Cor
 
Cor Ligthert said:
Hi Yves,

Using the directoryinfo that it easy, this is the same as creating your own
file dialog box with that.
http://msdn.microsoft.com/library/d...directoryinfoclassgetfilesysteminfostopic.asp

However what methode you use you should have to do code for it.
It does not appears in your program when you do not get the info from the
seperates directory.

Although you can use that dump methode using a dos command with redirection
of the output. However that I will never advice.

I hope this helps?

Cor


Thanks everybody for the replies.

Yves
 
Back
Top