My config:
I can't seem to use the UseAppInfo correctly. I don't want the app name in the path, just the path of the executable. I am trying this:
wxStandardPaths::Get().UseAppInfo(wxStandardPaths::AppInfo_None);
wxString strExe = wxStandardPaths::Get().GetExecutablePath();
strExe contains the full path and the executable name, despite the option AppInfo_None in UseAppInfo in the line above it. I am aware that I am getting an instance from a Get() which doesn't seem to be carried over in the next line.. The doc says to use wxStandardPaths through wxStandardPaths::Get().
I did tried the following as well, which doesn't work either (surprisingly it doesn't crash and does give me the full path including app name):
wxStandardPaths &path = wxStandardPaths::Get();
path.UseAppInfo(wxStandardPaths::AppInfo_None);
wxString strExe = path.GetExecutablePath();
Any suggestions?
wxGetCwd()
is not guaranteed to give the path to the application. In fact, you can change that path while the application is running using wxSetWorkingDirectory
.
The best method I have found to get the path to the application is to use GetExecutablePath
and use wxFileName
to remove the application name.
//need to include <wx/filename.h> and <wx/stdpaths.h>
wxFileName f(wxStandardPaths::Get().GetExecutablePath());
wxString appPath(f.GetPath());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With