1月15

查找指定文件

| |
21:37V B 源码  From: 本站原创
引用FSO.  
 
 
Private   Sub   Command1_Click()  
         Dim   fs   As   New   FileSystemObject     '   建立   FileSystemObject  
         Dim   fd   As   Folder         '   定义   Folder   对象  
         Dim   sfd   As   Folder  
 
         Set   fd   =   fs.GetFolder("c:\")'开始查找的目录  
         Command1.Enabled   =   False  
         Screen.MousePointer   =   vbHourglass  
         FindFile   fd,   Text1.Text   'TEXT1是要查找的文件类型.如*.TXT  
         Command1.Enabled   =   True  
         Screen.MousePointer   =   vbDefault  
 End   Sub  
  [separator]
 Sub   FindFile(fd   As   Folder,   FileName   As   String)  
         Dim   sfd   As   Folder,   f   As   File  
 
         '   Part   I查找该文件夹的所有文件  
         For   Each   f   In   fd.Files  
                 If   UCase(f.Name)   Like   UCase(FileName)   Then  
                         Debug.Print   f.Path  
                         List1.AddItem   f.Path  
                 End   If  
                 DoEvents  
         Next  
 
         '   Part   II循环查找所有子文件夹  
         For   Each   sfd   In   fd.SubFolders  
                 FindFile   sfd,   FileName     '   循环查找  
         Next  
 End   Sub


来源:夕阳醉了's Blog
地址:http://oznn.com/post/3/
转载时须以链接形式注明作者和原始出处及本声明!
阅读(3853) | 评论(0) | 引用(0)
发表评论
表情
emotemotemotemot
emotemotemotemot
emotemotemotemot
emotemotemotemot
emotemotemotemot
emotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]