Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get list of all filenames in a directory using VB6?

What is the simplest way in VB6 to loop through all the files in a specified folder directory and get their names?

like image 681
Ray Avatar asked Nov 15 '08 00:11

Ray


People also ask

How do I get a list of filenames in a folder?

3. Type "dir /b > dirlist. txt" without quotes and press "Enter." This creates a list containing file names only. To include file sizes and dates, type "dir > dirlist.

How do you get the names of all files in a folder in R?

To list all files in a directory in R programming language we use list. files(). This function produces a list containing the names of files in the named directory. It returns a character vector containing the names of the files in the specified directories.

How do I create a list of folders in Excel?

In the top toolbar, select the + New button, and then select Folder from the dropdown. , select List settings, and then select Advanced settings. In the Folders section, select Yes for Make "New Folder" command available.


2 Answers

sFilename = Dir(sFoldername)

Do While sFilename > ""

  debug.print sFilename 
  sFilename = Dir()

Loop
like image 150
DJ. Avatar answered Sep 28 '22 06:09

DJ.


Dim fso As New FileSystemObject
Dim fld As Folder
Dim fil As File
Set fld = fso.GetFolder("C:\My Folder")
For Each fil In fld.Files
  Debug.Print fil.Name
Next
Set fil = Nothing
Set fld = Nothing
Set fso = Nothing
like image 24
bigsancho Avatar answered Sep 28 '22 04:09

bigsancho