{"id":428,"date":"2010-12-21T18:21:35","date_gmt":"2010-12-21T18:21:35","guid":{"rendered":"https:\/\/ibex.tech\/visualcpp\/?p=428"},"modified":"2022-02-17T06:24:04","modified_gmt":"2022-02-17T06:24:04","slug":"special-directories","status":"publish","type":"post","link":"https:\/\/ibex.tech\/visualcpp\/file-input-output-serialization\/special-directories","title":{"rendered":"Special Directories"},"content":{"rendered":"<pre>\r\n<code>\r\nusing namespace System::Windows::Forms;\r\nusing namespace System::IO;\r\n<\/code><\/pre>\n<h4>\nExe path Directory<br \/>\n<\/h4>\n<pre>\r\n<code>\r\nReflection::Assembly::GetExecutingAssembly()-&gt;Location\r\n<\/code><\/pre>\n<h4>\nApplication Directory<br \/>\n<\/h4>\n<pre>\r\n<code>\r\nApplication path\r\n\tApplication::ExecutablePath\t\t\/\/This gives you the full path including the filename\r\n\r\n\tPath::GetDirectoryName(Application::ExecutablePath)\t\/\/This gives you the path to the directory (without trailing &#39;\\&#39;)\r\n<\/code><\/pre>\n<p>\nor use\n<\/p>\n<pre>\r\n<code>\r\n\tString ^sPath\r\n\tsPath = Application::ExecutablePath;\r\n\tsPath = Path::GetDirectoryName(sPath);\r\n<\/code><\/pre>\n<h4>\nLocation To Store Application Data<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n#define MY_FILE_DIRECTORY_TO_USE\t\tEnvironment::GetFolderPath(Environment::SpecialFolder::ApplicationData) + &quot;\\\\&quot; + Application::CompanyName + &quot;\\\\&quot; + Application::ProductName + &quot;\\\\&quot;\r\n<\/code><\/pre>\n<p>\nN.B.&nbsp;SpecialFolder::CommonApplicationData is not the same as&nbsp;ApplicationData. &nbsp;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. &nbsp;If your application uses&nbsp;CommonApplicationData you will find that it is unable to write to it under Windows 8 and possbily Windows 7. Use&nbsp;ApplicationData instead.\n<\/p>\n<h4>\nProgram Files \/ Program Files (x86)<br \/>\n<\/h4>\n<p>\nThis will always point to the 32bit folder, so&nbsp;&quot;C:\\Program Files&quot; on a 32bit&nbsp;platform and&nbsp;&quot;C:\\Program Files (x86)&quot; platform:\n<\/p>\n<pre>\r\n<code>\r\n\tMyString = Environment::GetFolderPath(Environment::SpecialFolder::ProgramFiles) + &quot;\\\\VideoLAN\\\\VLC\\\\&quot;;\r\n<\/code><\/pre>\n<h4>\nSystem Directories &amp; Locations<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n\tString ^ Path = System::Environment::SpecialFolder::Desktop;\r\n\tString ^ Path = Environment::GetFolderPath(Environment::SpecialFolder::MyDocuments);\r\n\r\nApplication::ProductName\r\nApplication::ProductVersion\r\nApplication::CompanyName\r\nApplication::CommonAppDataPath\t\/\/Includes ap version no as part of directory\r\nApplication::LocalUserAppDataPath\t\/\/Includes ap version no as part of directory\r\nApplication::StartupPath\t\t\/\/e.g. &quot;C:\\Program Files\\MyApp&quot;\r\nApplication::UserAppDataPath\r\nApplication::ExecutablePath\t\t\/\/Includes ApName.exe (fill path to the file)\r\n\r\nApplicationData\t\t\/\/Common repository for application-specific data for the current roaming user.\r\nCommonApplicationData\t\/\/Common repository for application-specific data that is used by all users.\r\nLocalApplicationData\t\/\/Common repository for application-specific data that is used by the current, non-roaming user.\r\nCookies\t\t\t\/\/Common repository for Internet cookies.\r\nDesktop\t\t\t\/\/The logical Desktop rather than the physical file system location.\r\nFavorites\t\t\t\/\/The directory that serves as a common repository for the user&#39;s favorite items.\r\nHistory\t\t\t\/\/The directory that serves as a common repository for Internet history items.\r\nInternetCache\t\t\/\/The directory that serves as a common repository for temporary Internet files.\r\nPrograms\t\t\t\/\/The directory that contains the user&#39;s program groups.\r\nMyComputer\t\t\t\/\/The &quot;My Computer&quot; folder.\r\nMyMusic\t\t\t\/\/The &quot;My Music&quot; folder.\r\nMyPictures\t\t\t\/\/The &quot;My Pictures&quot; folder.\r\nRecent\t\t\t\/\/The directory that contains the user&#39;s most recently used documents.\r\nSendTo\t\t\t\/\/The directory that contains the Send To menu items.\r\nStartMenu\t\t\t\/\/The directory that contains the Start menu items.\r\nStartup\t\t\t\/\/The directory that corresponds to the user&#39;s Startup program group.\r\nSystem\t\t\t\/\/The System directory.\r\nTemplates\t\t\t\/\/The directory that serves as a common repository for document templates.\r\nDesktopDirectory\t\t\/\/The directory used to physically store file objects on the desktop.\r\nPersonal\t\t\t\/\/The directory that serves as a common repository for documents.\r\nMyDocuments\t\t\t\/\/The &quot;My Documents&quot; folder.\r\nProgramFiles\t\t\/\/The program files directory.\r\nCommonProgramFiles\t\/\/The directory for components that are shared across applications.\r\n\r\ne,g,\r\nMyString = Environment::GetFolderPath(Environment::SpecialFolder::ProgramFiles) + &quot;\\\\VideoLAN\\\\VLC\\\\&quot;;<font face=\"Century Gothic, Arial, Helvetica, sans-serif\"><span style=\"font-size: 6px; white-space: normal;\">\r\n\r\n<\/span><\/font><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>using namespace System::Windows::Forms; using namespace System::IO; Exe path Directory Reflection::Assembly::GetExecutingAssembly()-&gt;Location 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 &#39;\\&#39;) 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) + [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[],"class_list":["post-428","post","type-post","status-publish","format-standard","hentry","category-file-input-output-serialization"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/comments?post=428"}],"version-history":[{"count":9,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/428\/revisions"}],"predecessor-version":[{"id":1344,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/428\/revisions\/1344"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/media?parent=428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/categories?post=428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/tags?post=428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}