请教使用scripting.filesystemobject的问题
文件夹下只有D:\cg\2.dwg,D:\cg\3.dwg,D:\cg\Drawing1.dwg这三个文档代码:
Set scr_obj = CreateObject("scripting.filesystemobject")
Set folder_obj = scr_obj.GetFolder(Text2.Text)
Set files_obj = folder_obj.Files
num=0
For Each file In files_obj
If Right(file.Name, 3) = "dwg" Then '是否为dwg
....
Debug.Print file.Path
num=num+1
end if
next
发现有时循环了三个文件,有时重复了一个文件,为什么呢?
运行结果:
****************
D:\cg\2.dwg
D:\cg\3.dwg
D:\cg\Drawing1.dwg
****************
D:\cg\3.dwg
D:\cg\Drawing1.dwg
D:\cg\2.dwg
D:\cg\3.dwg
****************
页:
[1]