VC下判斷檔案是否存在

2021-04-19 20:26:23 字數 655 閱讀 4668

方法1:

#include

#include

#include

void main( void )

}方法2:

if (invalid_handle_value != createfile("d://a.txt", generic_read, file_share_read, null, open_existing, file_attribute_normal, null))

方法3:

#define _win32_winnt 0x0400

#include

#include

int main(int argc, char *argv)

else }

方法4:

if (getfileattributes("c://1.txt") == -1)

messagebox(0."invalid file ","hehe",0)

else

messagebox(0."the first file found ","haha",0)

方法5:

if (invalid_handle_value != createfile("d://a.txt", 0, 0, null, open_existing, 0, null))

VC下判斷檔案是否存在

方法1 include include include void main void 方法2 if invalid handle value createfile d a.txt generic read,file share read,null,open existing,file attribu...

VC下判斷檔案是否存在

方法1 include include include void main void 方法2 if invalid handle value createfile d a.txt generic read,file share read,null,open existing,file attribu...

VC 判斷檔案是否存在

1.使用 access函式,函式原型為 int access const char path,int mode 2.使用createfile函式,函式原型為 handle createfile lpctstr lpfilename,pointer to name of the file dword ...