当我使用代码
Properties.Settings.Default.Save();
保存我的设置,将文件写入该路径
%USERPROFILE%\AppData\Local\MyAppName\MyAppName.exe_Url_SomeWiredCode\TheAppVersionNumber\user.config
喜欢
"C:\Users\Username\AppData\Local\MyApp\MyApp.exe_Url_claumreyuxtgqul2vuc3couyu5tso2n0\1.0.0.0\user.config"
如何获取“应用程序版本”文件夹的路径,以便可以向其中写入其他内容?
我正在使用.Net Framework 4.6.2和Visual Studio 2017。
您应该能够像这样检索文件路径:
var level = ConfigurationUserLevel.PerUserRoamingAndLocal;
var configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(level);
var configurationFilePath = configuration.FilePath
为了使这项工作,你需要添加引用System.Configuration.dll
(右键单击您的WPF项目,选择添加,引用...并选中旁边的复选框System.Configuration
中的组件/框架页。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句