Funny thing is that something seemingly correct like
Code: Select all
bool TestIfFileExists(const wxString& fileName)
{
wxFileName fn(fileName);
if ( !fn.Normalize(wxPATH_NORM_ENV_VARS) )
{
wxLogError("Could not normalize file name '%s'", fileName);
return false;
}
const bool exists = fn.FileExists();
wxLogMessage("File '%s' %s.", fn.GetFullPath(), exists ? "exists" : "does not exist");
return exists;
}
TestIfFileExists("c:\\users\\%username%\\appdata\\roaming\\microsoft\\signatures")
is not going to work either, as wxExpandEnvVars() considers those "%" to be escaped by preceding slash as explained in the wxPATH_NORM_ENV_VARS description. However, something like
Code: Select all
TestIfFileExists("%appdata%\\microsoft\\signatures")
should work, except the path is a folder, not a file.