MFC: Create Directory

Original link: How
to check if Directory already Exists in MFC(VC++)?

MSDN Links:

CreateDirectory
function

GetFileAttributes
function

GetLastError
function

System
Error Codes

Example:

VC++  MFC DLL project


#include "stdafx.h"
#include <windows.h>
#include <Shellapi.h>

// To check if a file/folder exists:

// Method 1: GetFileAttributes
// Description:
// Retrieves file system attributes for a specified file or directory.
// Return value:
// a) If the function succeeds, the return value contains the attributes of the specified file or directory. For a list of attribute values and their descriptions, see File Attribute Constants.
// b) If the function fails, the return value is INVALID_FILE_ATTRIBUTES. To get extended error information, call GetLastError.
if (GetFileAttributes(szDirPath) == INVALID_FILE_ATTRIBUTES) {
CreateDirectory(szDirPath,NULL);
}

// Method 2: CreateDirectory
// Description:
// Creates a new directory
// Return value:
// a) If the function succeeds, the return value is nonzero.
// b) If the function fails, the return value is zero. To get extended error information, call GetLastError.
if(!CreateDirectory(szDirPath,NULL))
{
if (GetLastError() == ERROR_ALREADY_EXISTS) {
// directory already exists
} else {
// creation failed due to some other reasons
}
}

MFC: Create Directory,布布扣,bubuko.com

时间: 2024-08-05 11:00:28

MFC: Create Directory的相关文章

【翻译自mos文章】windows下 11gR2 安装报错:&quot;PRKN-1019 : Failed to create directory&quot;

来源于: 11gR2 Installation on Windows fails with "PRKN-1019 : Failed to create directory" (文档 ID 1669683.1) 适用于: Oracle Database - Enterprise Edition - Version 11.2.0.3 and later Microsoft Windows x64 (64-bit) - Version: 2008 R2 症状: 在windows下安装 11.

Crontab could not create directory .ssh

最近在利用 crontab 构建自动备份时,遇到了一个问题.我的脚本中包含了用于服务器用户切换使用的 ssh 命令.当我登录到服务器上时,脚本执行正常:当我没有登录到服务器上时,脚本执行失败,错误提示是: Could not create directory '/home/server/.ssh' 在登录到服务器上后,可以看到 "/home/server/.ssh" 路径是存在的,也是正常的. 各个用户间的 ssh key 也已经生成好了,在登录到服务器上后,手动调用主脚本,可以正常的

[hadoop]Cannot create directory /mdrill/tablelist/fact_seller_all_d. Name node is in safe mode.

在执行mdrill创建表的时候报如下异常(蓝色部分为关键): [[email protected] bin]$ ./bluewhale mdrill create ./create.sql higo execute [create, ./create.sql] Exception in thread "main" org.apache.hadoop.ipc.RemoteException: org.apache.hadoop.hdfs.server.namenode.SafeModeE

Gradle Goodness: Task Output Annotations Create Directory Automatically

Gradle Goodness: Task Output Annotations Create Directory Automatically One of the great features of Gradle is incremental build support. With incremental build support a task is only executed if it is really necessary. For example if a task generate

vsftp关于&quot;550 create directory operation failed&quot;问题解决

前提: 昨天晚上配置好了vsftp, 但登陆后,除了浏览,什么也干不了.(如新建文件/文件夹, 删除文件, 重命名等都不可操作) 都是弹出 "550 create directory operation failed" 的错误信息. 查看文件夹属性, 然后改了什么用户都可读写, 结果还是一样. 配置文件有问题? 应该不会啊, 以前一向都是这样配置的啊. 还是有点不相信自己, 拿了以前的 vsftpd.conf 配置文件过来. 问题依旧, 郁闷ing..... 正解: 是SELinux(

initramfs-tools ... update-initramfs: Generating /boot/initrd.img-3.14-kali1-amd64 mktemp: failed to create directory via template `/var/tmp/mki

Processing triggers for initramfs-tools ...update-initramfs: Generating /boot/initrd.img-3.14-kali1-amd64mktemp: failed to create directory via template `/var/tmp/mkinitramfs_XXXXXX': No such file or directoryupdate-initramfs: failed for /boot/initrd

svn提交错误:Commit failed (details follow): Can&#39;t create directory

重装系统后,启动svn,挂载原来的repository目录,访问正常,但提交时老发生以下错误: Commit failed (details follow): Can't create directory ***.txn: No such file or directory google一把,看到碰到这样问题的倒也不少,解决办法不多.下面这篇文章里得到个提醒:svn的repository目录转移到新机器时不要直接使用,要用svnadmin dump/load来拷贝使用.于是dump & load

linux vsftpd 550 create directory operation failed解决方法

今天配置好了vsftp, 但登陆后,除了浏览,什么也干不了.(如新建文件/文件夹, 删除文件, 重命名等都不可操作) 都是弹出 "550 create directory operation failed" 的错误信息. 查看文件夹属性, 然后改了什么用户都可读写, 结果还是一样. 配置文件有问题? 应该不会啊, 以前一向都是这样配置的啊. 还是有点不相信自己, 拿了以前的 vsftpd.conf 配置文件过来. 问题依旧, 郁闷ing..... 正解:       是SELinux(

使用Docker Compose 部署Nexus后提示:Unable to create directory /nexus-data/instance

场景 Ubuntu Server 上使用Docker Compose 部署Nexus(图文教程): https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/101111611 在上面部署好Nexus后,启动后日志提示: Unable to create directory /nexus-data/instance 注: 博客:https://blog.csdn.net/badao_liumang_qizhi关注公众号霸道的程序猿获取编程