1 Replies - 532 Views - Last Post: 01 May 2011 - 07:35 AM Rate Topic: -----

#1 podypodpod  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 21-January 11

Text file searching and file path retrieval

Posted 01 May 2011 - 02:19 AM

im trying to get a list of all the text files present (there file paths) in a certain folder (lets say C:\Users\podypodpod\Desktop\textfiles) and then add them to the list box (lb_Entrys)

ive manage to find this code to get all text files from the desktop , but i cant manage to edit it so i can give an actual filepath for it to search


        For Each foundFile As String In My.Computer.FileSystem.GetFiles( _  
        My.Computer.FileSystem.SpecialDirectories.Desktop, _
        FileIO.SearchOption.SearchAllSubDirectories, "*.txt")

            lb_Entrys.Items.Add(foundFile)
        Next



Is This A Good Question/Topic? 0
  • +

Replies To: Text file searching and file path retrieval

#2 Ionut  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 385
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: Text file searching and file path retrieval

Posted 01 May 2011 - 07:35 AM

nothing happens if you change My.Computer.FileSystem.SpecialDirectories.Desktop
with your path?
You may try working with System.IO.Directory.GetFiles() method.
Dim FoundFiles() as String

FoundFiles = System.IO.Directory.GetFiles(<your_path_here>)
'loop through FoundFiles with a for each 


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1