C++判断文件夹是否存在
2013-02-01 14:58
183 查看
一、判断文件夹是否存在:
1.用CreateDirectory(".//FileManege",NULL);如果文件夹FileManege不存在,则创建。
2.或者if(_access(".//FileManege",0)==-1),表示FileManege不存在。
3.或者BOOL PathIsDirectory(LPCTSTR pszPath);
二、判断文件是否存在:
1.用if((file=fopen(".//FileManege//F//F.dat","rb"))==NULL)
file=fopen(".//FileManege//F//F.dat","ab+"); // 先判断有无文件,没的话新建一个
2.用if(_access(".//FileManege//F//F.dat",0)==-1),表示文件不存在。
函数int _access( const char *path, int mode );可以判断文件或者文件夹的mode属性
mode=00;//Existence only
mode=02;//Write permission
mode=04;//Read permission
mode=06;//Read and write permission
需要包含头文件<io.h>。
1.用CreateDirectory(".//FileManege",NULL);如果文件夹FileManege不存在,则创建。
2.或者if(_access(".//FileManege",0)==-1),表示FileManege不存在。
3.或者BOOL PathIsDirectory(LPCTSTR pszPath);
二、判断文件是否存在:
1.用if((file=fopen(".//FileManege//F//F.dat","rb"))==NULL)
file=fopen(".//FileManege//F//F.dat","ab+"); // 先判断有无文件,没的话新建一个
2.用if(_access(".//FileManege//F//F.dat",0)==-1),表示文件不存在。
函数int _access( const char *path, int mode );可以判断文件或者文件夹的mode属性
mode=00;//Existence only
mode=02;//Write permission
mode=04;//Read permission
mode=06;//Read and write permission
需要包含头文件<io.h>。
相关文章推荐
- 判断文件夹、文件是否存在、创建文件 c++ matlab
- C++遍历文件夹及判断某一文件或目录是否存在
- c++判断文件或文件夹是否存在--转载
- c++判断文件夹是否存在,若不存在,调用linux命令创建它
- c++ 判断文件或文件夹是否存在
- C++判断文件夹是否存在
- C/C++判断文件/文件夹是否存在
- C/C++ 判断文件夹是否存在以及创建、删除文件夹 windows以及linux通用
- C++文件与文件夹操作(1)--判断文件和文件夹是否存在
- C/C++判断文件/文件夹是否存在 转
- [C/C++相关]C语言判断文件夹或者文件是否存在的方法
- C++ 获取文件夹内的文件名,判断文件(夹)是否存在的两个函数
- C/C++中判断文件或文件夹是否存在
- C# C++ 判断文件 文件夹是否存在
- C++ - 判断文件夹(folder)是否存在(exist)
- C/C++判断文件/文件夹是否存在
- C/C++ 判断文件夹是否存在以及创建、删除文件夹 windows以及linux通用
- C++ - 判断文件夹(folder)是否存在(exist)
- C++判断文件夹是否存在
- c++ 判断文件夹是否存在