刪除資料夾和資料夾下東西

2021-06-06 17:03:42 字數 606 閱讀 6424

解決的辦法:

/** * 刪除資料夾

* @param filepathandname string 資料夾路徑及名稱 如c:/fqf

* @param filecontent string

* @return boolean

*/public void delfolder(string folderpath)

catch (exception e)

}/**

* 刪除資料夾裡面的所有檔案

* @param path string 資料夾路徑 如 c:/fqf

*/public void delallfile(string path)

if (!file.isdirectory())

string templist = file.list();

file temp = null;

for (int i = 0; i < templist.length; i++)

else

if (temp.isfile())

if (temp.isdirectory())

}}

刪除資料夾和資料夾下的檔案

c 沒有刪除檔案的功能,可借助windows api實現該功能,還可以依據呼叫c執行庫函式實現刪除功能。mfc程式中 刪除檔案的函式為deletefile 刪除資料夾的函式為removedirectory 參考自 刪除資料夾和資料夾下的子檔案函式實現如下 bool deletedirectory c...

python 實現徹底刪除資料夾和資料夾下的檔案

python 中有很多內建庫可以幫忙用來刪除資料夾和檔案,當面對要刪除多個非空資料夾,並且目錄層次大於3層以上時,僅使用一種內建方法是無法達到徹底刪除資料夾和檔案的效果的,比較low的方式是多次呼叫直到刪除。但是,我們可以結合多個內建庫函式,達到一次刪除非空資料夾,不管其目錄層次有多深。import...

刪除檔案和資料夾

一 刪除檔案 使用 del 命令,可以檢視幫助資訊 del p f s q a attributes names erase p f s q a attributes names names 指定乙個或數個檔案或目錄列表。萬用字元可被用來 刪除多個檔案。如果指定了乙個目錄,目錄中的所 有檔案都會被刪...