wolfshou 发表于 2010-5-25 17:10:43

判断一个文件是否存在用什么函数啊?

我用fopen打开文件路径,if((fp=fopen(路径,r))==NULL),然后运行时提示有错误,应该怎么判断文件存在啊?谢谢帮助一下我 这个小虾

cvifan 发表于 2010-5-25 20:53:04

If an error occurs, OpenFile returns –1 and sets the last error status to one of the following values. To get the last error status, call GetFmtIOError.
FmtIOMaxFilesErr    256 files open already.
FmtIOInvalArgErr    Filename is NULL or contains only whitespace.
FmtIOInvalArgErr    Invalid Read/Write Mode, Action, or File Type.
In addition, OpenFile sets the error status to a system–dependent value if an error occurs opening the file. For more information about these values, see the library help.

cvifan 发表于 2010-5-25 20:53:29

并不是NULL,而是负值

cvifan 发表于 2010-5-25 20:53:51

打开正确无错误就存在,并能能读取到数据

wolfshou 发表于 2010-5-26 09:27:20

谢谢各位帮忙

wolfshou 发表于 2010-5-26 10:15:09

还需要请教一下,用access函数总是出现错误,好像是定义类型错误,为什么啊?帮忙解答一下吧,谢谢
页: [1]
查看完整版本: 判断一个文件是否存在用什么函数啊?