VC 資料夾的建立和資料夾的刪除總結

2021-06-28 05:28:39 字數 1073 閱讀 6398

****:

假設我想判斷c:\program files中有沒有乙個名為hotel的資料夾,有的話就什麼也不做,沒有的話就建立乙個名為hotel的資料夾,

請問這個**應該怎麼寫呢?(能建立乙個隱藏的資料夾更好)

//答案

bool createdirectory(

lpctstr lppathname, // directory name

lpsecurity_attributes lpsecurityattributes

// pointer to a security_attributes structure

);

要判斷資料夾是否存在,首先用cfindfile類得到檔案(可以判斷是否存在),存在的話用isdirectory判斷是否資料夾

bool pathisdirectory(

lpctstr pszpath

);判斷乙個目錄是否存在!

**例項:

#include #include using namespace std;

int main()

vc如何刪除檔案下的檔案

bool cdlgdata::deletedirectory(char *sdirname)

else

} }

tempfind.close();

if(!removedirectory(sdirname))

return true;

}

注釋deletedirectory(stempdir); 

這個函式只能刪除空目錄。你必須先刪除裡面的所有檔案才行

可以用winshellapi int winapi shfileoperation (

lpshfileopstruct lpfileop

);函式刪除包含檔案的目錄

VB 刪除帶子資料夾和檔案的資料夾

如下 sub recursetree currpath as string currpath問資料夾路徑 dim sfilename as string,newpath as string,spath as string static oldpath as string spath currpath...

VB刪除帶子資料夾和檔案的資料夾

刪除帶子資料夾和檔案的資料夾 程式 sub recursetree currpath as string currpath問資料夾路徑 dim sfilename as string,newpath as string,spath as string static oldpath as string...

刪除檔案和資料夾

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