Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Make Use Of DirectoryInfo 2

Status
Not open for further replies.

RebelFox

Programmer
Jun 16, 2002
62
0
0
GB
I am trying to make sense of the new VB.Net suite after using VB6 for some time. I have just tried an example from a Wrox book that works fine but I can’t quite understand. The example is shown below.


What I don’t understand is the line:-

objSubFolders = New DirectoryInfo(“C:\”).GetDirectories

I can see the objSubFolders DirectoryInfo object is populated by the statement starting with ‘New’. But my dim mind can’t grapple with why the compiler does not accept the statement:-

objSubFolders(“C:\”).GetDirectories

ObjSubFolders is a DirectoryInfo object so why does it not behave like a direct execution of the DirectoryInfo.




General Declarations

‘ Import NameSpace With All Classes Below It
‘ Including DirectoryInfo
Imports System.IO



Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click


‘ Define Object
Dim objSubFolders() As DirectoryInfo ‘


‘ Define Instance
objSubFolders = New DirectoryInfo(“C:\”).GetDirectories

Dim objSubFolder As DirectoryInfo
For Each objSubfolder In SubFolders
lstListBox1.Items.Add(subfolder.FullName)
Next

End Sub
 
objSubFolders(“C:\”).GetDirectories

this cant work because objsubfolders is an array of ellements that have the type directoryinfo

so this will give you the information of the first directory

objsubfolders(0).fullname

objsubfolders.getupperbound(0) will give you how many directorys you got




Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top