DirectoryInfo question

  • Thread starter Thread starter csharpula csharp
  • Start date Start date
C

csharpula csharp

Hello,
I got an object of DirectoryInfo and I would like to know how can I get
the names of all child directories of this folder?

Thank you!
 
Hello,
I got an object of DirectoryInfo and I would like to know how can I get
the names of all child directories of this folder?

Thank you!

*** Sent via Developersdexhttp://www.developersdex.com***

Hi,
I think you want to get subfolders of a folder;

using System.IO;
DirectoryInfo dirinfo = new DirectoryInfo("path_of_main_folder");
// For example get subfolders into a listbox control
listBox1.Items.AddRange(dirinfo.GetDirectories());

Thanks,

Onur Güzel
 
Hi csharpula,

Then just use the method GetDirectories() which returns a collection of DirectoryInfo
to iterate through.

DirectoryInfo directoryInfoObject = new DirectoryInfo( .... );
foreach (DirectoryInfo childFolder in directoryInfoObject.GetDirectories())
{ ..... }

Regards, Alex
 
csharpula csharp said:
Hello,
I got an object of DirectoryInfo and I would like to know how can I get
the names of all child directories of this folder?

DirectoryInfo di = new DirectoryInfo();
DirectoryInfo[] subDirs = di.GetDirectories();

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top