您的位置:首页 > 其它

如何判断文件文件夹是否存在

2008-06-03 17:39 501 查看
PathFileExists 函数可以用来查看一个文件或文件夹是否存在。

在使用这个函数时,要注意两点:
1. 加入#include <shlwapi.h>.
2. 在project(工程)->setting(设置)->link(连接)下objiect/library modules(对象/库模块)中加入shlwapi.lib.

使用例子:

(1).判断文件

CString strFile = "E://darcy//example//test.txt"

if (PathFileExists(strFile) == 1)
{
MessageBox("该文件存在", "操作结果", MB_ICONQUESTION);
}

(2).判断文件夹

CString strPath = "E://darcy//example"

if (PathFileExists(strPath) == 1)
{
MessageBox("该文件夹存在", "操作结果", MB_ICONQUESTION);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: