views:

41

answers:

2

Hello

How would I be able to make a variable that holds the value of the directories that exist in the C:\ Simple question to answer...

Thanks

Kevin

+3  A: 

The DirectoryInfo class has member functions to do that - GetDirectories in this case.

Imports System.IO

Dim fTarget As New IO.DirectoryInfo("C:\")
Dim arrAnswer as DirectoryInfo()
arrAnswer = fTarget.GetDirectories()
Aramis wyler
Yep. And technically, you can create a variable of the type DirectoryInfo
David Stratton
Aye, if you really wanted to see a whole folder tree, you'd want to write a function and call it recursively to populate an array of names, probably with an extra column to reflect it's parent folder.
Aramis wyler
A: 

The simplest option is to call GetDirectories on the static type Directory. This can be found in System.Io. It returns a string array of directories that it finds. You can also specify if it should drill down into subcategories when it is called

See msdn for more info http://msdn.microsoft.com/en-us/library/system.io.directory.getdirectories.aspx

WDuffy