Last active
December 30, 2015 05:49
-
-
Save frhd/7785591 to your computer and use it in GitHub Desktop.
c++ check if file exists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the full path of the .exe, ANSI format | |
string ExePath() { | |
char buffer[MAX_PATH]; | |
GetModuleFileNameA( NULL, buffer, MAX_PATH ); | |
string::size_type pos = string( buffer ).find_last_of( "\\/" ); | |
return string( buffer ).substr( 0, pos); | |
} | |
// Check if file exists | |
bool IniFileExists(string file) { | |
string c = ExePath() + "\\" + file; | |
ifstream ifexfile(c.c_str()); | |
if (ifexfile) | |
return TRUE; | |
else | |
return FALSE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment