怎么用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
要求首先选取一个文件夹,然后依次读文件夹下面的每个文件,该怎么做?
我用的是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