复制出IE临时文件夹内的SWF文件

'复制出IE临时文件夹内的SWF文件,也可以是其他类型的文件,这里只是简单演示用FSO遍历文件夹
'引用Microsoft Scripting RunTime
Dim m_objFSO As New FileSystemObject   '定义文件系统对象

Private Declare Function SHGetSpecialFolderLocation Lib "Shell32" (ByVal hwndOwner As Long, ByVal nFolder As Integer, ppidl As Long) As Long
Private Declare Function SHGetPathFromIDList Lib "Shell32" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal szPath As String) As Long
Const MAX_LEN = 200 '字符串最大长度
Const PAGETMP = &H20& '网页临时文件

Private Sub Command1_Click()
    Dim sTmp As String * MAX_LEN '存放结果的固定长度的字符串
    Dim nLength As Long '字符串的实际长度
    Dim pidl As Long '某特殊目录在特殊目录列表中的位置
    Dim TStr As String
   
    '获得网页临时文件夹
    SHGetSpecialFolderLocation 0, PAGETMP, pidl
    SHGetPathFromIDList pidl, sTmp
    TStr = Left(sTmp, InStr(sTmp, Chr(0)) - 1)
    SearchSwf TStr
End Sub

Private Sub SearchSwf(strPath As String)
    Dim objFolder   As Scripting.Folder   '文件夹对象
    Dim objFile   As Scripting.File   '文件对象
    Dim objSubdirs   As Scripting.Folders   '文件夹集合对象
    Dim objLoopFolder   As Scripting.Folder   '文件夹对象
   
    Set objFolder = m_objFSO.GetFolder(strPath)
   
    For Each objFile In objFolder.Files
        If UCase$(Right$(objFile.ShortPath, 4)) = ".SWF" Then
            FileCopy objFile.Path, "c:/TestSwf/" & objFile.Name
        End If
    Next objFile
   
    Set objSubdirs = objFolder.SubFolders
   
    For Each objLoopFolder In objSubdirs
        SearchSwf objLoopFolder.Path
    Next objLoopFolder
   
    Set objSubdirs = Nothing
    Set objFolder = Nothing
End Sub

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值