请举例说明,解决后马上放分!一定要纯C,谢谢!

解决方案 »

  1.   

    你用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.
      

  2.   

    HANDLE FindFirstFile(
      LPCTSTR lpFileName,
      LPWIN32_FIND_DATA lpFindFileData
    );
      

  3.   

    struct ffblk myFfblk;int nFind=findfirst(curPath,&myFfblk,FA_RDONLY|FA_LABEL|FA_HIDDEN|FA_DIREC|FA_SYSTEM|FA_ARCH);
    ……if((myFfblk.ff_attrib&FA_DIREC)) //文件夹
    ……
    nFind=findnext(&myFfblk);
      

  4.   

    #include <stdio.h>
    #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;
    }
      

  5.   

    或者你在IDE下查帮助,相关的都有
      

  6.   

    _access函数
    例子:
    #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" );
       }
    }