例如:C:\test\test是合法的。c:\\test是不合法的。
还有怎样建立一个多级目录。如:c:\test\t2
还有怎样建立一个多级目录。如:c:\test\t2
解决方案 »
- 我写的一个ARP测试工具,有几个问题,希望高手能帮忙。
- VS2008 重新安装时出错
- 在VC中如何实现关闭窗口但不退出整个主程序
- 郁闷!为UI界面美工设计被老板训,弟兄们帮我出出招
- 请问DWORD类型数据如何转换呢?
- 自己作仪表的ActiveX控件可以吗?很难吧?
- 怎么解决???????????
- C++老师的作业,编一个记事本,不能用Edit控件,大家帮忙看看!
- 怎样解释运行 javascript,有没有现成的javascript 解释器可以用?
- 请教:关于CreateService()。。。。。
- 关于在主框架窗口中如何添加工具栏的问题?高手帮帮忙!
- 怎么将其它对话框中的控件导到自已的对话框里?
多级目录:MakeSureDirectoryPathExists
看这个贴子
http://expert.csdn.net/Expert/topic/2350/2350491.xml?temp=.8053705
if(file.Create(.....))
Return TRUE;//合法的
else
return FALSE;//不合法
BOOL PathFileExists(
LPCTSTR pszPath
);
示例如下:
#include <windows.h>
#include <iostream.h>
#include "Shlwapi.h"void main( void )
{
// Valid file path name (file is there).
char buffer_1[ ] = "C:\\TEST\\file.txt";
char *lpStr1;
lpStr1 = buffer_1;// Invalid file path name (file is not there).
char buffer_2[ ] = "C:\\TEST\\file.doc";
char *lpStr2;
lpStr2 = buffer_2;
// Return value from "PathFileExists".
int retval;// Search for the presence of a file with a true result.
retval = PathFileExists(lpStr1);
if(retval == 1)
{
cout << "Search for the file path of : " << lpStr1 << endl;
cout << "The file requested \"" << lpStr1 << "\" is a valid file" << endl;
cout << "The return from function is : " << retval << endl;
}else{
cout << "\nThe file requested " << lpStr1 << " is not a valid file" << endl;
cout << "The return from function is : " << retval << endl;
}// Search for the presence of a file with a false result.
retval = PathFileExists(lpStr2);
if(retval == 1)
{
cout << "\nThe file requested " << lpStr2 << "is a valid file" << endl;
cout << "Search for the file path of : " << lpStr2 << endl;
cout << "The return from function is : " << retval << endl;
}else{
cout << "\nThe file requested \"" << lpStr2 << "\" is not a valid file" << endl;
cout << "The return from function is : " << retval << endl;
}
}
参看MSDN中PathFileExists的例子说明:
……
char buffer_1[] = "C:\\TEST\\file.txt";
……
retval = PathFileExists(lpStr1);
if(retval == 1)
……2、agree akiko(弥弥)
CreateDirectory(YourDirectory,NULL)//if func return Nonzero indicates success
//return Zero indicates failure
存在则肯定是合法
不存在可以CreateDirectroy();
如果失败,则非法
如果不失败,可以RemoveDirectory();
合法