Probably the most painfull part about getting this together was the fact that my compiler did not understand INVALID_FILE_ATTRIBUTES, so I had to do a cast thingy and check for ((DWORD)-1).
Also, I did not remember that c++ is sensitive to backslashes, so...
c:\test
should really be
c:\\test
Enjoy.....
Prototype....
A sample call....Code:bool FolderExists(string file);//function prototype
Function definition....Code:bool folderexist; folderexist=FolderExists("c:\\test2"); cout << folderexist;
Code:bool FolderExists(string file) { DWORD returnvalue; returnvalue = GetFileAttributes(file.c_str()); if(returnvalue == ((DWORD)-1)) { return false; } else { return true; } }





Reply With Quote