如何确定指定目录在磁盘中是否存在(有此种函数吗?) 有没有此种函数,能直接确定目录的存在性? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CFileFind f;if(f.Find(szPathName)) //Directory exist.else //Not exist. 两个办法:1、 CFileFind f; if(f.FindFile("c:\\temp")) AfxMessageBox("存在"); //Directory exist. else AfxMessageBox("不存在"); //Not exist.2、 if(_access("c:\\temp", 0) == 0){ AfxMessageBox("存在"); } else{ AfxMessageBox("不存在"); } hFile = CreateFile("c:\\somedir\\..", //judge whether // directory // c:\\somedire exists GENERIC_READ, // open for reading FILE_SHARE_READ, // share for reading NULL, // no security OPEN_EXISTING, // existing file only FILE_ATTRIBUTE_NORMAL, // normal file NULL); // no attr. template if (hFile == INVALID_HANDLE_VALUE) { printf("directory doesn't exist\n"); // process error } else{ CloseHandle(hFile); printf("directory exists\n");} WIN32_FIND_DATA FindData; HANDLE hFind=FindFirstFile("C:\\Mydir",&FindData);if(hFind!=LPWIN32_FIND_DATA && (FindData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)){ CloseHandle(hFind); /*目录在磁盘中存在*/}else{ /*目录在磁盘中不存在*/} 粘贴错了,第三行应该是if(hFind!=INVALID_HANDLE_VALUE && 如何使VC中的工具栏按钮(最好含文字)的大小可以随窗口大小的改变而改变 请教代码含义 菜鸟学vc,再问几个弱问题~~关于创建dll给vb用的。 VC/MFC/Win32程序员技术测试二--使用Windowsx.h进行消息分流 怎样编制一个虚拟的音频设备? 动态创建的非模式对话框如何获得窗口句柄? 是 .Net 的问题吗? _beginthread()非常简单的问题。 请看这两行代码 请问,AfxMessageBox 和 MessageBox两个函数的区别 想要一个,短小的jpg2bmp的dll 或原码 不用SMTP服务器如何实现邮件的发送啊?有高分相送!
if(f.Find(szPathName))
//Directory exist.
else
//Not exist.
1、
CFileFind f;
if(f.FindFile("c:\\temp"))
AfxMessageBox("存在");
//Directory exist.
else
AfxMessageBox("不存在");
//Not exist.2、
if(_access("c:\\temp", 0) == 0){
AfxMessageBox("存在");
}
else{
AfxMessageBox("不存在");
}
// directory
// c:\\somedire exists
GENERIC_READ, // open for reading
FILE_SHARE_READ, // share for reading
NULL, // no security
OPEN_EXISTING, // existing file only
FILE_ATTRIBUTE_NORMAL, // normal file
NULL); // no attr. template
if (hFile == INVALID_HANDLE_VALUE)
{
printf("directory doesn't exist\n"); // process error
}
else
{ CloseHandle(hFile);
printf("directory exists\n");
}
HANDLE hFind=FindFirstFile("C:\\Mydir",&FindData);
if(hFind!=LPWIN32_FIND_DATA && (FindData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
{
CloseHandle(hFind);
/*目录在磁盘中存在*/
}
else
{
/*目录在磁盘中不存在*/
}
if(hFind!=INVALID_HANDLE_VALUE &&