Skip to content

Instantly share code, notes, and snippets.

@frhd
Last active December 30, 2015 05:49
Show Gist options
  • Save frhd/7785591 to your computer and use it in GitHub Desktop.
Save frhd/7785591 to your computer and use it in GitHub Desktop.
c++ check if file exists
// 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