有什么API函数吗?怎么判断有没有读写的权限?

解决方案 »

  1.   

    BOOL PathFileExists(LPCTSTR lpszPath);
      

  2.   

    WIN32_FIND_DATA FileData;
    HANDLE handle = FindFirstFile(lpFileName, &FileData);
    if(handle == INVALID_HANDLE_VALUE)  //如果不存在
    return FALSE;
    FindClose(handle);用 DWORD GetFileAttributes(LPCTSTR lpFileName);
    获得文件属性,以之判断读写权限。
      

  3.   

    函数access(),用法:#include <io.h>if(access("c:\\test.txt", 0) == -1)
    {
    AfxMessageBox("c:\\test.txt不存在");
    }
      

  4.   

    我这样使用,
    #include <windows.h>
    #include <iostream.h>
    #include "Shlwapi.h"if(!PathFileExists(".\\config.ini"))
    {
    AfxMessageBox("File not exist");
    }但是出现如下错误:
    ainFrm.obj : error LNK2001: unresolved external symbol __imp__PathFileExistsA@4请问是什么原因,我看MSDN也没有说到,
      

  5.   

    int _access( const char *path, int mode );
    //该函数用来判断指定的文件是否存在
    例子:#include  <io.h>
    #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" );
       }
    }
      

  6.   

    project--setting--link--Object/library modules加上Shlwapi.lib