你用fopen打开路径下的文件 如果返回了NULL 那么就没有该文件 如果返回了 那就打开了 fopen, _wfopen Open a file.Function Required Header fopen <stdio.h> _wfopen <stdio.h> FILE *fopen( const char *filename, const char *mode ); FILE *_wfopen( const wchar_t *filename, const wchar_t *mode ); Parameters filename Filename mode Type of access permitted Libraries All versions of the C run-time libraries.The c, n, and t mode options are Microsoft extensions for fopen and should not be used where ANSI portability is desired.Return Values Each of these functions returns a pointer to the open file. A null pointer value indicates an error. Res The fopen function opens the file specified by filename. _wfopen is a wide-character version of fopen; the arguments to _wfopen are wide-character strings. _wfopen and fopen behave identically otherwise.
如果返回了NULL
那么就没有该文件
如果返回了
那就打开了
fopen, _wfopen
Open a file.Function Required Header
fopen <stdio.h>
_wfopen <stdio.h>
FILE *fopen( const char *filename, const char *mode );
FILE *_wfopen( const wchar_t *filename, const wchar_t *mode );
Parameters
filename
Filename
mode
Type of access permitted
Libraries
All versions of the C run-time libraries.The c, n, and t mode options are Microsoft extensions for fopen and should not be used where ANSI portability is desired.Return Values
Each of these functions returns a pointer to the open file. A null pointer value indicates an error. Res
The fopen function opens the file specified by filename. _wfopen is a wide-character version of fopen; the arguments to _wfopen are wide-character strings. _wfopen and fopen behave identically otherwise.
LPCTSTR lpFileName,
LPWIN32_FIND_DATA lpFindFileData
);
……if((myFfblk.ff_attrib&FA_DIREC)) //文件夹
……
nFind=findnext(&myFfblk);
#include <dos.h>int main(void)
{
struct find_t ffblk;
int done;
printf("Directory listing of *.*\n");
done = _dos_findfirst("*.*",_A_NORMAL,&ffblk);//_A_SUBDIR表示子目录,_A_NORMAL表示目录和文件
while (!done)
{
printf(" %s\n", ffblk.name);
done = _dos_findnext(&ffblk);
}
return 0;
}
例子:
#include <io.h>
#include <stdio.h>
#include <stdlib.h>int main( void )
{
/* Check for existence */
if( (_access( "crt_ACCESS.C", 0 )) != -1 )
{
printf( "File crt_ACCESS.C exists\n" );
/* Check for write permission */
/* assume file is read-only */
if( (_access( "crt_ACCESS.C", 2 )) == -1 )
printf( "File crt_ACCESS.C does not have write permission\n" );
}
}