RDir
FileNameArray = RDir ( Directory AS String [ , Pattern AS String , Filter AS Integer , FollowLink AS Boolean ] ) AS String[]
返回位于Directory目录及其子目录中与Pattern和Filter条件匹配的文件名,并存储于一个字符串数组中。
指定的目录被递归遍历。
Pattern可以包含与
LIKE操作一样的通配符。如果没有指定Pattern,会返回任何文件名。
Filter指定将返回何种类型的文件。
Filter可以是下列值之一:
如果没有指定Filter,会返回所有的文件和目录。
如果FollowLink为
TRUE,那么对目录的符号连接被递归遍历,否则会被像普通文件一样处理。
Since 3.20
If you add the
gb.FullPath
constant to the
Options argument, the
Directory path is added to each returned file.
Note that the pattern does not apply to the directory part in that case.
Pattern匹配整个相对路径,而不仅仅是文件名。
所以,如果想查找文件
"/usr/share/icons/locolor/32x32/apps/libreoffice4.1-impress.png"
,应该用:
RDir("/usr", "*libreoffice4.1-impress.png")
而非:
RDir("/usr", "libreoffice4.1-impress.png")
上面这个将不返回任何东西。
示例
' 打印directory目录及其子目录中的png图像文件名
SUB PrintDirectory(Directory AS String)
DIM File AS String
FOR EACH File IN RDir(Directory, "*.png")
PRINT File
NEXT
END
参见