12

How can you obtain a list of files (as a stringcollection or some other storage method) which contains the full path on the user's computer to the files?

Is there a method for doing so?

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
Cyclone
  • 17,939
  • 45
  • 124
  • 193

3 Answers3

21

It looks like you want to use Directory.GetFiles() in the System.IO namespace.

Docs here.

brettkelly
  • 27,655
  • 8
  • 56
  • 72
4
    Dim txtFiles = Directory.GetFiles("C:\Input", "*.CSV", SearchOption.TopDirectoryOnly).
        [Select](Function(nm) Path.GetFileName(nm))

    Dim arrayList As New System.Collections.ArrayList()
    For Each filenm As String In txtFiles
        arrayList.Add(New clsImportFiles(filenm))
    Next
sansalk
  • 4,595
  • 2
  • 36
  • 37
3

Add a Listbox to Windows Form and Add following code on Form Load or other events :-

ListBox1.Items.AddRange(Directory.GetFiles("Your Directory PAth Here"))

Hope IT Helps ; From Nirav

Nirav
  • 31
  • 1