问题如题目:
我是这样做的
CFile mfile;
if(mfile.Open("test.dat",CFile::modeRead,NULL)==0)
{
AfxMessageBox("file test.dat is not exist",NULL,0);
return;
}
mfile.Close();但是这样做开销太大(进行磁盘访问操作),有没有好的方法?
我是这样做的
CFile mfile;
if(mfile.Open("test.dat",CFile::modeRead,NULL)==0)
{
AfxMessageBox("file test.dat is not exist",NULL,0);
return;
}
mfile.Close();但是这样做开销太大(进行磁盘访问操作),有没有好的方法?
BOOL FileExists(LPCTSTR lpszFileName)
{
WIN32_FIND_DATA wfd;
BOOL bRet;
HANDLE hFind;
hFind = FindFirstFile(lpszFileName, &wfd);
bRet = hFind != INVALID_HANDLE_VALUE;
FindClose(hFind);
return bRet;
}
);Header shlwapi.h
Import library shlwapi.lib
sPath="*****";
CFileFind fFind;
if(fFind.FindFile(lpszFileName))
//找到
#include <stdio.h>
#include <stdlib.h>void main( void )
{
/* Check for existence */
if( (_access( "ACCESS.C", 0 )) != -1 )
{
printf( "File ACCESS.C exists\n" );
/* Check for write permission */
if( (_access( "ACCESS.C", 2 )) != -1 )
printf( "File ACCESS.C has write permission\n" );
}
}