looping thru a DirectoryInfo

Results 1 to 2 of 2

Thread: looping thru a DirectoryInfo

  1. #1
    Join Date
    Dec 1969

    Default looping thru a DirectoryInfo

    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>&#039; this would giveme a list of file names<BR>dir.getFiles<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: looping thru a DirectoryInfo

    Use a foreach loop:<BR><BR>Dim f as File<BR>For Each f in dir.getFiles<BR> &#039;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> &#039; access the current guy via dir.getFiles.Item(i)<BR>Next i<BR><BR>hth

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts