C/C++判断文件/文件夹是否存在 转
2016-12-04 14:56
218 查看
一、判断文件夹是否存在:
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>。
转自:http://luzongping1986.blog.163.com/blog/static/788129152009379452504/
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>。
转自:http://luzongping1986.blog.163.com/blog/static/788129152009379452504/
相关文章推荐
- C# C++ 判断文件 文件夹是否存在
- C++ 判断文件文件夹是否存在
- C/C++判断文件/文件夹是否存在
- C/C++判断文件/文件夹是否存在
- C/C++判断文件文件夹是否存在
- C++文件与文件夹操作(1)--判断文件和文件夹是否存在
- C++用Windows API判断文件或文件夹是否存在
- C++遍历文件夹及判断某一文件或目录是否存在
- c++判断文件或文件夹是否存在--转载
- 判断文件夹、文件是否存在、创建文件 c++ matlab
- VC C++ 判断文件夹中是否存在某个文件
- [C/C++相关]C语言判断文件夹或者文件是否存在的方法
- c++ 判断文件、文件夹(路径)是否存在
- c++ 判断文件或文件夹是否存在
- C++ 获取文件夹内的文件名,判断文件(夹)是否存在的两个函数
- C/C++判断文件/文件夹是否存在
- C/C++中判断文件或文件夹是否存在
- C#中判断文件或文件夹是否存在
- C#怎样判断文件是否存在和文件夹是否存在
- C/C++中判断某一文件或目录是否存在