Quantcast
Channel: Relative path Winform C++
Viewing all articles
Browse latest Browse all 3

Relative path Winform C++

$
0
0
Is this a managed C++ application?  If so, you can extract the directory name from Application.ExecutablePath to get the path to concatenate to your relative path.

 
String^ s = System::IO::Path::Combine(  
    System::IO::Path::GetDirectoryName(System::Windows::Forms::Application::ExecutablePath),  
    "image\\image1.bmp");  
 

(Using a relative path directly is unreliable because the working directory can change.  OpenFileDialog/SaveFileDialog is the usual culprit for changing the working directory on you.)

If this is not a managed application, then this is the wrong forum.  (But look into GetModuleFileName http://msdn.microsoft.com/en-us/library/ms683197.aspx with hModule = NULL to do the same kind of thing as Application.ExecutablePath.)


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>