c++ - GetFileAttributes returning FILE_ATTRIBUTE_ARCHIVE for nonexistent file -


i'm using getfileattributes check existence before creating file, , displaying dialog user (standard "do want replace existing file")

if (getfileattributes(szfilepath) != 0xffffffff) { /* display "do want replace?"*/} 

occasionally, return success file cannot possibly exist, since folder in has just been created (using createdirectory). when does, attributes returns file_attribute_archive.

any idea what's going on?

edit: in response endless series of "you should use invalid_file_attributes instead" have done so.

dword dwfile = getfileattributes(szfilepath); if (dwfile != invalid_file_attributes) { /* display "do want replace?"*/} 

i same result. dwfile returned file_attribute_archive file not exist. quite sure not exist. folder created. not using gettempfilename(). can copy szfilepath debugger , visit folder using both explorer , command line, neither of them showing file existing.

ok, turns out holdover dos. specific filename important. following line of code reproduce issue, assuming c:\aux.c doesn't exist on system, , have 'c' drive. (my initial encounter behavior deep in tree, minimal case.)

dword dwfile = getfileattributes(text("c:\\aux.c")); 

it's related question on over superuser why file apparently not exist when attempting delete it? there filenames protected, when file doesn't exist, , has never existed.

con, prn, aux, clock$, nul, com1, com2, com3, com4, com5, com6, com7, com8, com9 lpt1, lpt2, lpt3, lpt4, lpt5, lpt6, lpt7, lpt8, , lpt9.

these protected, , can cause problems if run case trying edit/create/delete them on windows.


Comments