looping thru a DirectoryInfo

KaLaM eL3ieN

New Member
How do I loop thru a DirectoryInfo files collection and assign each filename into an array? I need to process each filename in the array before displaying them?<BR><BR>Dim dir as New DirectoryInfo(Server.MapPath("SFTNews"))<BR>'this would giveme a list of file names<BR>dir.getFiles<BR>Use a foreach loop:<BR><BR>Dim f as File<BR>For Each f in dir.getFiles<BR> 'do whatever<BR>Next<BR><BR>At least I think you can do that in VB.NET, you can in C#. If nothing else you could iterate through the collection (i.e., dir.getFiles) using a standard For loop, something like:<BR><BR>For i = 0 to dir.getFiles.Count<BR> ' access the current guy via dir.getFiles.Item(i)<BR>Next i<BR><BR>hth
 
Back
Top