using namespace System::Windows::Forms;
using namespace System::IO;

Exe path Directory


Application Directory

Application path
	Application::ExecutablePath		//This gives you the full path including the filename

	Path::GetDirectoryName(Application::ExecutablePath)	//This gives you the path to the directory (without trailing '\')

or use

	String ^sPath
	sPath = Application::ExecutablePath;
	sPath = Path::GetDirectoryName(sPath);

Location To Store Application Data

#define MY_FILE_DIRECTORY_TO_USE		Environment::GetFolderPath(Environment::SpecialFolder::ApplicationData) + "\\" + Application::CompanyName + "\\" + Application::ProductName + "\\"

N.B. SpecialFolder::CommonApplicationData is not the same as ApplicationData.  Non-Admin users and applications running as a non admin user do not have permission to write to the CommonApplicationData folder, because that folder does not belong to specific users.  If your application uses CommonApplicationData you will find that it is unable to write to it under Windows 8 and possbily Windows 7. Use ApplicationData instead.

Program Files / Program Files (x86)

This will always point to the 32bit folder, so "C:\Program Files" on a 32bit platform and "C:\Program Files (x86)" platform:

	MyString = Environment::GetFolderPath(Environment::SpecialFolder::ProgramFiles) + "\\VideoLAN\\VLC\\";

System Directories & Locations

	String ^ Path = System::Environment::SpecialFolder::Desktop;
	String ^ Path = Environment::GetFolderPath(Environment::SpecialFolder::MyDocuments);

Application::CommonAppDataPath	//Includes ap version no as part of directory
Application::LocalUserAppDataPath	//Includes ap version no as part of directory
Application::StartupPath		//e.g. "C:\Program Files\MyApp"
Application::ExecutablePath		//Includes ApName.exe (fill path to the file)

ApplicationData		//Common repository for application-specific data for the current roaming user.
CommonApplicationData	//Common repository for application-specific data that is used by all users.
LocalApplicationData	//Common repository for application-specific data that is used by the current, non-roaming user.
Cookies			//Common repository for Internet cookies.
Desktop			//The logical Desktop rather than the physical file system location.
Favorites			//The directory that serves as a common repository for the user's favorite items.
History			//The directory that serves as a common repository for Internet history items.
InternetCache		//The directory that serves as a common repository for temporary Internet files.
Programs			//The directory that contains the user's program groups.
MyComputer			//The "My Computer" folder.
MyMusic			//The "My Music" folder.
MyPictures			//The "My Pictures" folder.
Recent			//The directory that contains the user's most recently used documents.
SendTo			//The directory that contains the Send To menu items.
StartMenu			//The directory that contains the Start menu items.
Startup			//The directory that corresponds to the user's Startup program group.
System			//The System directory.
Templates			//The directory that serves as a common repository for document templates.
DesktopDirectory		//The directory used to physically store file objects on the desktop.
Personal			//The directory that serves as a common repository for documents.
MyDocuments			//The "My Documents" folder.
ProgramFiles		//The program files directory.
CommonProgramFiles	//The directory for components that are shared across applications.

MyString = Environment::GetFolderPath(Environment::SpecialFolder::ProgramFiles) + "\\VideoLAN\\VLC\\";

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.


Your email address will not be published. Required fields are marked *