会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
水滴石穿
VC中判断目录,文件是否存在,创建目录的方法
VC中判断目录,文件是否存在,创建目录的方法
2007-08-10 11:26
目录是否存在的检查:
BOOL FolderExist(CString strPath)
{
WIN32_FIND_DATA wfd;
BOOL rValue
=
FALSE;
HANDLE hFind
=
FindFirstFile(strPath,
&
wfd);
if
((hFind
!=
INVALID_HANDLE_VALUE)
&&
(wfd.dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY))
{
rValue
=
TRUE;
}
FindClose(hFind);
return
rValule;
}
文件存在性检查:
BOOL FileExist(CString strFileName)
{
CFileFind fFind;
return
fFind.FindFile(strFileName);
}
创建目录:
BOOL CreateFolder(CString strPath)
{
SECURITY_ATTRIBUTES attrib;
attrib.bInheritHandle
=
FALSE;
attrib.lpSecurityDescriptor
=
NULL;
attrib.nLength
=
sizeof
(SECURITY_ATTRIBUTES);
//
上面定义的属性可以省略。 直接return ::CreateDirectory( path, NULL); 即可
return
::CreateDirectory( strPath,
&
attrib);
}
posted on
2007-09-03 11:41
步走高飞
阅读(
13834
) 评论(
1
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
导航
新随笔
管理
公告