lang • rdir


FileNameArray = RDir ( Directory AS String [ , Pattern AS String , Filter AS Integer , FollowLink AS Boolean ] ) AS String[]

Returns a string array that contains the names of files located in Directory and its sub-directories that matches the Pattern and the Filter.

The specified directory is recursed.

The pattern can contain the same generic characters than the LIKE operator. If no pattern is specified, any file name is returned.

The filter specifies what kind of files will be returned.

The filter can be one of the following values:

  • gb.File for returning only files.

  • gb.Directory for returning only directories.

  • gb.File + gb.Directory for returning both.

If Filter is not specified, all files and directories are returned.

If FollowLink is TRUE, then symbolic links on directories are recursed. Otherwise they are processed like normal files.

The file paths returned are relative to the searched directory.

The pattern matches the full relative path, not just the file name.

So, if you wanted to find the file "/usr/share/icons/locolor/32x32/apps/libreoffice4.1-impress.png", you must write:

    RDir("/usr", "*libreoffice4.1-impress.png")

and not:

    RDir("/usr", "libreoffice4.1-impress.png")

which will return nothing.


' Print the png image files in a directory and its sub-directories

Sub PrintDirectory(Directory As String)

  Dim File As String

  For Each File In RDir(Directory, "*.png")
    Print File


See also