vc判断文件是否存在

 我来答
paradise300
推荐于2016-09-22 · TA获得超过3566个赞
知道大有可为答主
回答量:2589
采纳率:84%
帮助的人:524万
展开全部

方法一:PathFileExists(FilePath);   返回true则存在,返回false则不存在,注意要加上以下代码:

#include <shlwapi.h>
#pragma comment(lib,"Shlwapi.lib")

方法二:CFile::GetStatus(WMSIniFilePath,filestatus),返回true则存在,返回false则不存在

参数: 

rStatus:

A reference to a user-supplied CFileStatus structure that will receive the status information. The CFileStatus structure has the following fields:

 

CTime m_ctime   The date and time the file was created.
 

CTime m_mtime   The date and time the file was last modified.

CTime m_atime   The date and time the file was last accessed for reading.
 

LONG m_size   The logical size of the file in bytes, as reported by the DIR command.
 

BYTE m_attribute   The attribute byte of the file.

 

char m_szFullName[_MAX_PATH]   The absolute filename in the Windows character set.

 

lpszFileName:

A string in the Windows character set that is the path to the desired file. The path can be relative or absolute, but cannot contain a network name.

 

 

参考:http://msdn.microsoft.com/zh-cn/aa270504

C语言爱好者123
2014-01-23
知道答主
回答量:50
采纳率:0%
帮助的人:9.3万
展开全部
虽然现在的函数更新很快,但有种东西叫经典,它含有权威
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式