古詩詞大全網 - 四字成語 - vc判斷文件是否存在

vc判斷文件是否存在

兩種方式我測試過 其中“WMSIniFilePath”是文件名+路徑

1、MFC類庫

int?IniPathFileExists()

{

CFileStatus?fs;

if?(!CFile::GetStatus(WMSIniFilePath,fs))

{

return?0;//不存在

}

return?1;//存在

}2、

//開頭加上

#include?<shlwapi.h>

#pragma?comment(lib,"Shlwapi.lib")

int?IniPathFileExists()

{

if?(!PathFileExists(WMSIniFilePath))

{

return?0;//不存在

}

return?1;//存在

}