怎样用函数判断一个文件是否存在? 有什么API函数吗?怎么判断有没有读写的权限? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 BOOL PathFileExists(LPCTSTR lpszPath); WIN32_FIND_DATA FileData; HANDLE handle = FindFirstFile(lpFileName, &FileData); if(handle == INVALID_HANDLE_VALUE) //如果不存在 return FALSE; FindClose(handle);用 DWORD GetFileAttributes(LPCTSTR lpFileName);获得文件属性,以之判断读写权限。 函数access(),用法:#include <io.h>if(access("c:\\test.txt", 0) == -1){ AfxMessageBox("c:\\test.txt不存在");} 我这样使用,#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也没有说到, 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" ); }} project--setting--link--Object/library modules加上Shlwapi.lib 连接指针运行Execute就出错 做课设,问几个问题! [求助]DirectX编写程序Debug版正常,改成Release版 有N多错误 我有几个很大很大的正整数要相加(整数有128位)请大家帮我想想有什么方法??? 求救:MSDN2003怎么让VS6.0用F1呼出来? 哪里有VC编译错误大全之类的书啊?要电子版的,解决了坚决给分 请问有关工具条的问题! windows下netstat命令是如何实现的? 请帮忙 图像放大和缩小问题 高手请进!急 请问如何判断一个机器的某个udp端口是否开着?
HANDLE handle = FindFirstFile(lpFileName, &FileData);
if(handle == INVALID_HANDLE_VALUE) //如果不存在
return FALSE;
FindClose(handle);用 DWORD GetFileAttributes(LPCTSTR lpFileName);
获得文件属性,以之判断读写权限。
{
AfxMessageBox("c:\\test.txt不存在");
}
#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也没有说到,
//该函数用来判断指定的文件是否存在
例子:#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" );
}
}