{"id":418,"date":"2018-12-28T14:30:42","date_gmt":"2018-12-28T05:30:42","guid":{"rendered":"http:\/\/marius.main.jp\/software\/blog\/?p=418"},"modified":"2020-03-25T18:05:10","modified_gmt":"2020-03-25T09:05:10","slug":"post-418","status":"publish","type":"post","link":"https:\/\/todosoft.net\/blog\/?p=418","title":{"rendered":"\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30c7\u30fc\u30bf\u4fdd\u5b58\u5834\u6240\u306e\u53d6\u5f97"},"content":{"rendered":"\n<p>Windows7\u306eVirtualStore\u304c\u767b\u5834\u3059\u308b\u524d\u306f\u3001<br>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30c7\u30fc\u30bf\u3092EXE\u3068\u540c\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u8a2d\u7f6e\u3057\u3059\u308b\u3053\u3068\u3067\u3001<br>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u524a\u9664\u3057\u305f\u3044\u969b\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3054\u3068\u524a\u9664\u3059\u308b\u3060\u3051\u3067<br>\u74b0\u5883\u3092\u6c5a\u3055\u305a\u306b\u51e6\u7406\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u305f\u3002<\/p>\n\n\n\n<p>\u3057\u304b\u3057VirtualStore\u5b9f\u88c5\u4ee5\u964d\u3001ProgramFiles\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u8a2d\u7f6e\u3057\u305f\u5834\u5408\u3001<br>\u6700\u65b0\u306e\u30c7\u30fc\u30bf\u306fAppData\u306b\u683c\u7d0d\u3055\u308c\u3066\u3057\u307e\u3044\u3001ProgramFiles\u306b\u4fdd\u5b58\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u624b\u3067\u5909\u66f4\u3057\u305f\u3068\u3057\u3066\u3082\u3001<br>AppData\u306e\u30c7\u30fc\u30bf\u3067\u4e0a\u66f8\u304d\u3055\u308c\u3066\u3057\u307e\u3046\u554f\u984c\u304c\u767a\u751f\u3059\u308b\u3002<\/p>\n\n\n\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u3001 ProgramFiles\u306b\u8a2d\u7f6e\u3057\u3088\u3046\u304c\u3001\u4ed6\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u8a2d\u7f6e\u3057\u3088\u3046\u304c\u3001<br>AppData\u306b\u30c7\u30fc\u30bf\u3092\u683c\u7d0d\u3057\u3066\u3057\u307e\u3048\u3070\u826f\u3044\u3068\u3044\u3046\u8003\u3048\u65b9\u3082\u3042\u308b\u304c\u3001<br>\u306a\u308b\u3079\u304f\u3067\u3042\u308c\u3070\u3001ProgramFiles\u4ee5\u5916\u306e\u5834\u5408\u306fEXE\u3068\u540c\u3058\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u8a2d\u7f6e\u3057\u305f\u3044\u3068\u8003\u3048\u3001<br>\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3067\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30d1\u30b9\u53d6\u5f97\u3092\u884c\u3063\u305f\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<pre class=\"wp-block-luxe-blocks-syntaxhighlighter line-numbers language-csharp\"><code class=\"language-csharp\">using System;\nusing System.IO;\nusing System.Reflection;\n\nnamespace UserClass\n{\n    public static class AppDataPath\n    {\n        \/\/\/ &lt;summary>\n        \/\/\/ \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30c7\u30fc\u30bf\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u53d6\u5f97\n        \/\/\/ (VirtualStore\u8003\u616e)\n        \/\/\/ &lt;\/summary>\n        \/\/\/ &lt;returns>&lt;\/returns>\n        public static string GetAppDataPath()\n        {\n            string strPath = \"\";\n\n            try\n            {\n                \/\/ EXE\u306e\u3042\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u683c\u7d0d\n                strPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);\n\n                if (Environment.Is64BitOperatingSystem)\n                {\n                    \/\/ 64BitOS\n\n                    if ((strPath.IndexOf(Environment.GetEnvironmentVariable(\"ProgramFiles(x86)\")) >= 0) ||\n                        (strPath.IndexOf(Environment.GetEnvironmentVariable(\"ProgramW6432\")) >= 0))\n                    {\n                        \/\/ ProgramFiles\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5834\u5408\u306fLOCALAPPDATA(VirtualStore)\u3092\u8fd4\u3059\n                        strPath = GetLocalApplicationData();\n                    }\n                }\n                else\n                {\n                    \/\/ 32BitOS\n\n                    if (strPath.IndexOf(Environment.GetEnvironmentVariable(\"ProgramFiles\")) >= 0)\n                    {\n                        \/\/ ProgramFiles\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5834\u5408\u306fLOCALAPPDATA(VirtualStore)\u3092\u8fd4\u3059\n                        strPath = GetLocalApplicationData();\n                    }\n                }\n\n                \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u7121\u3051\u308c\u3070\u69cb\u7bc9\n                if (Directory.Exists(strPath) == false)\n                    Directory.CreateDirectory(strPath);\n            }\n            catch (Exception ex)\n            {\n                throw (ex);\n            }\n\n            return strPath;\n        }\n\n        \/\/\/ &lt;summary>\n        \/\/\/ %LOCALAPPDATA%[\u4f1a\u793e\u540d][\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u540d]\n        \/\/\/ &lt;\/summary>\n        \/\/\/ &lt;returns>&lt;\/returns>\n        private static string GetLocalApplicationData()\n        {\n            string strPath = \"\";\n\n            AssemblyTitleAttribute asmttl = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute));\n            AssemblyCompanyAttribute asmcmp = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCompanyAttribute));\n\n            strPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);\n            strPath = Path.Combine(strPath, asmcmp.Company);\n            strPath = Path.Combine(strPath, asmttl.Title);\n\n            return strPath;\n        }\n    }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Windows7\u306eVirtualStore\u304c\u767b\u5834\u3059\u308b\u524d\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30c7\u30fc\u30bf\u3092EXE\u3068\u540c\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u8a2d\u7f6e\u3057\u3059\u308b\u3053\u3068\u3067\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u524a\u9664\u3057\u305f\u3044\u969b\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3054\u3068\u524a\u9664\u3059\u308b\u3060\u3051\u3067\u74b0\u5883\u3092\u6c5a\u3055\u305a\u306b\u51e6\u7406\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u305f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,20,15],"tags":[23],"class_list":["post-418","post","type-post","status-publish","format-standard","hentry","category-c","category-wpf","category-15","tag-wpf"],"_links":{"self":[{"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/418","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=418"}],"version-history":[{"count":5,"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/418\/revisions"}],"predecessor-version":[{"id":723,"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/418\/revisions\/723"}],"wp:attachment":[{"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}