如题所述
æè¿å¨å¦ä¹ .NETçæ¶ï¼éè¦å¨å®¢æ·ç«¯è½¯ä»¶ä¸ä¿åç¨æ·çä¸äºè®¾ç½®ï¼æ¯å¦æ¯å¦å¨ç»å½æ¡ä¸ä¿åä¸æ¬¡ç»å½åçä¿¡æ¯ï¼å°±ç¨å°äº.NETä¸çåºç¨ç¨åºè®¾ç½®åè½ãå¦æ使ç¨ç¨æ·èå´ç设置ï¼ç¨åºä¼å¨ç£çä¸å建user.configç¨æ¥åå¨ä¿®æ¹å设置å¼ï¼å¯¹ user.configæå¨çæ件夹ï¼æ产çäºä¸äºå
´è¶£ï¼å¹¶åäºä¸äºç 究ãç°ä¸¾ä¸ªä¾åæ¥è¯´æï¼
C:/Documents and Settings/Admin/Local Settings/Application Data/Microsoft/test.exe_Url_3ypvtlafqkef0gkp1kl5i2idjssaxajb/1.0.0.0/user.config
å ¶ä¸
âC:/Documents and Settings/Admin/Local Settings/Application Dataâæ¯LocalApplicationDataç¹æ®æ件夹
âMicrosoftâç¨åºéçååå称
âAdminâæ¯å½åWindowsç¨æ·å
âtest.exeâæ¯ç¨åºéå好å称
â1.0.0.0âæ¯ç¨åºéçæ¬
âuser.configâæ¯åå¨ç¨æ·é 置信æ¯çæ件ï¼è¯¥æ件举ä¾å¦ä¸ï¼
âUrl_3ypvtlafqkef0gkp1kl5i2idjssaxajbâ该å符串æ¯å°ç¨åºéçååä¿¡æ¯ãçæ¬ä¿¡æ¯ãç»å¯¹è·¯å¾è¿è¡åå¸è®¡ç®ï¼å¾å°çå¯ä¸å¼ï¼å¯é¿å ä¸åçç¨åºçæç¸åçæ件路å¾ã
å¦æè¦æ³éè¿ç¼ç¨çæ¹å¼å¯¹user.configæ件åä¸äºçµæ´»çæ§å¶ï¼å°±å¿ é¡»å¾å°è¯¥æ件çç»å¯¹è·¯å¾ï¼ä¸ºäºè·å.NETçæuser.configå¯
ä¸è·¯å¾çæ¹æ³ï¼æ使ç¨Reflectoråç¼è¯äºSystem.Configç¨åºéï¼ç»äºå¾å°äºå ¶ä¸çæ¹æ³ï¼åäºä¸äºç®åãç°åä¸äºä»ç»ï¼
ï¼1ï¼ClientConfigPathsç±»ï¼åªæä¸ä¸ªpublicæ¹æ³GetUserConfigFilePathï¼æ¤æ¹æ³å³å¯è·åuser.configçç»å¯¹è·¯å¾;
ï¼2ï¼StringUtilç±»ï¼ä¸ä¸ªè¾ å©ç±»ï¼ç¨æ¥åä¸äºå符串æä½
ï¼3ï¼ä½¿ç¨æ¹æ³ï¼
ClientConfigPaths ccp = new ClientConfigPaths();
textBox1.Text = ccp.GetUserConfigFilePath();
C:/Documents and Settings/Admin/Local Settings/Application Data/Microsoft/test.exe_Url_3ypvtlafqkef0gkp1kl5i2idjssaxajb/1.0.0.0/user.config
å ¶ä¸
âC:/Documents and Settings/Admin/Local Settings/Application Dataâæ¯LocalApplicationDataç¹æ®æ件夹
âMicrosoftâç¨åºéçååå称
âAdminâæ¯å½åWindowsç¨æ·å
âtest.exeâæ¯ç¨åºéå好å称
â1.0.0.0âæ¯ç¨åºéçæ¬
âuser.configâæ¯åå¨ç¨æ·é 置信æ¯çæ件ï¼è¯¥æ件举ä¾å¦ä¸ï¼
âUrl_3ypvtlafqkef0gkp1kl5i2idjssaxajbâ该å符串æ¯å°ç¨åºéçååä¿¡æ¯ãçæ¬ä¿¡æ¯ãç»å¯¹è·¯å¾è¿è¡åå¸è®¡ç®ï¼å¾å°çå¯ä¸å¼ï¼å¯é¿å ä¸åçç¨åºçæç¸åçæ件路å¾ã
å¦æè¦æ³éè¿ç¼ç¨çæ¹å¼å¯¹user.configæ件åä¸äºçµæ´»çæ§å¶ï¼å°±å¿ é¡»å¾å°è¯¥æ件çç»å¯¹è·¯å¾ï¼ä¸ºäºè·å.NETçæuser.configå¯
ä¸è·¯å¾çæ¹æ³ï¼æ使ç¨Reflectoråç¼è¯äºSystem.Configç¨åºéï¼ç»äºå¾å°äºå ¶ä¸çæ¹æ³ï¼åäºä¸äºç®åãç°åä¸äºä»ç»ï¼
ï¼1ï¼ClientConfigPathsç±»ï¼åªæä¸ä¸ªpublicæ¹æ³GetUserConfigFilePathï¼æ¤æ¹æ³å³å¯è·åuser.configçç»å¯¹è·¯å¾;
ï¼2ï¼StringUtilç±»ï¼ä¸ä¸ªè¾ å©ç±»ï¼ç¨æ¥åä¸äºå符串æä½
ï¼3ï¼ä½¿ç¨æ¹æ³ï¼
ClientConfigPaths ccp = new ClientConfigPaths();
textBox1.Text = ccp.GetUserConfigFilePath();
温馨提示:答案为网友推荐,仅供参考