首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

怎么用VB遍历一个文件夹下的所有文件

2012-01-26 
如何用VB遍历一个文件夹下的所有文件?要求首先选取一个文件夹,然后依次读文件夹下面的每个文件,该怎么做?

如何用VB遍历一个文件夹下的所有文件?
要求首先选取一个文件夹,然后依次读文件夹下面的每个文件,该怎么做?

我用的是Open   "c:\test\a.txt "   For   Random   As   #1   Len   =   Len(c)来读一个确定的文件,主要是依次确定每个文件名不知道该怎么做.

分不多了,大家帮帮我啊

[解决办法]
dim s as string
dim sFullPath as string

s = dir( "c:\test\*.txt ")
while lenb(s) <> 0
if (s <> ". ") and (s <> ".. ") then
sFullPath = "c:\test\ " & s
if (getattr(sfullpath) and vbdirectory) <> vbdirectory then
'读取文件 sFullPath
...
end if
end if
s = dir()
wend

热点排行