刪除資料夾及其子資料夾中所有tmp字尾的檔案

2021-05-22 17:40:47 字數 848 閱讀 7906

option explicit

const window_handle = 0

const options = 0

const file_type = "*.tmp"

if vartype(objfolder) = vbstring then

dim fso

set fso = createobject("scripting.filesystemobject")

call deletefileinfolder(objfolder.items.item.path, file_type)

set fso = nothing

end if

set objshell = nothing

'***************=sub********************===

'迭代刪除資料夾及其子資料夾中所有word字尾的檔案

sub deletefileinfolder(byval path, byval word)

on error resume next

call fso.deletefile(path & "/" & word, true)

if err <> 0 then

err = 0

end if

dim folder

set folder = fso.getfolder(path)

dim subfolder

for each subfolder in  folder.subfolders

call deletefileinfolder(subfolder.path, word)

next

end sub

C 遍歷資料夾及其子檔案(夾)

c 遍歷資料夾及其子檔案 夾 如下 int finder lpctstr pstr 一般檔案及資料夾 printf d s n i finder.getfilename bool bisdir finder.isdirectory if bisdir else end while finder.cl...

刪除子資料夾

你是一位系統管理員,手裡有乙份資料夾列表 folder,你的任務是要刪除該列表中的所有 子資料夾,並以 任意順序 返回剩下的資料夾。我們這樣定義 子資料夾 如果資料夾 folder i 位於另乙個資料夾 folder j 下,那麼 folder i 就是 folder j 的子資料夾。資料夾的 路徑...

C 獲取資料夾中所有檔案

獲取資料夾中的檔案,用到過很多次,每次用的時候都要去查下,很煩,所以想自己寫下,當然,借鑑了很多其他大佬的部落格 主要實現的函式,如下 1 void getfiles string path,vector files 2 19else 20 23 while findnext hfile,filei...