List the files in a folder.

      Dir [( path [, attributes ] ) ]

   path   Path to a file, folder, or directory.
          If the path is not found, dir will return a zero-length string.

          The sum of the file attributes.
          One or a combination of the following values:

0  vbNormal (Default)
1  vbReadOnly
2  vbHidden
4  vbSystem System file
8  vbVolume Volume label
16 vbDirectory
64 vbAlias

Wildcards * and ? can be used to return multiple files.

To test if a folder (or server) exists at all, you can use this function from Allen Browne

Function FolderExists(strPath As String) As Boolean
   On Error Resume Next     
   FolderExists = ((GetAttr(strPath) And vbDirectory) = vbDirectory) 
End Function


'List a filename

'Check if a file exists
If Len(Dir("C:\docs\demo.xls")) = 0 Then Msgbox "File not found!"

'Check if a folder exists
If Len(Dir("C:\docs", vbDirectory)) = 0 Then Msgbox "Folder not found!"

“Is not the whole world a vast house of assignation of which the filing system has been lost?” ~ Quentin Crisp


MkDir - Create directory

© Copyright SS64.com 1999-2016
Some rights reserved