访问另一个应用程序的"user.config".文件 [英] Accessing another application's "user.config" file

查看:98
本文介绍了访问另一个应用程序的"user.config".文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

关于此问题,我还有另一篇文章,但是由于上一篇文章没有引起人们的注意,这次我将尝试更好地说明自己(抱歉两次发布)!

情况如下:
我有一个名为WinFormsProj1的WinForms项目.我在此项目中有几个设置,这些设置保存在"user.config"文件中(位于"C:\ Users \KåreTragethon \ AppData \ Local \ WinFormsProj1 \ WinFormsProj1.exe_Url _ ******** \ VersionNo \ user.config").在主应用程序(WinFormsProj1)中,可以通过以下方式找到"user.config"的路径:

Hi all!

I have another post about this issue, but I will try to explain myself a bit better this time (sorry for posting 2 times) since the previous post did not get any attention!

Here''s the situation:
I have a WinForms project called WinFormsProj1. I have several settings in this project which are saved in a "user.config" file (which lies in "C:\Users\Kåre Tragethon\AppData\Local\WinFormsProj1\WinFormsProj1.exe_Url_********\VersionNo\user.config"). From my main application (WinFormsProj1) I can find the path of the "user.config" by:

Configuration _usrConfigLoc = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);



然后



And then

string _filePath = _userConfigLoc.FilePath;



在同一解决方案中,我还有另一个名为WinFormsProj2的项目.我想从我的WinFormsProj2项目访问user.config文件到WinFormsProj1.如何找到文件路径?

我必须指出,我要查找的路径不是"C:\ Program Files \ WinFormsProj1 ......"!我正在寻找位于"C:\ Users \ User \ AppData \ Local \ AppName \ AppName.exe_Url _ *********"中的user.config文件的路径.



In the same solution I also have another project called WinFormsProj2. I want to access the user.config file to WinFormsProj1 from my WinFormsProj2 project. How can I find the file path?

I must point out that the path I am looking for is NOT the "C:\Program Files\WinFormsProj1......"!! I am looking for the path of the user.config file which lies in "C:\Users\The User\AppData\Local\AppName\AppName.exe_Url_*********"

推荐答案

尝试以下CodeProject文章:

在应用程序之间共享用户设置 [
Try this CodeProject article:

Share User Settings Between Applications[^]

fixed link as quotes were being escaped


嗨.

感谢您与我分享!!

我可能应该提到我对C#(以及一般而言的计算机编程)还很陌生,所以说实话,我不完全了解您在项目中所做的一切.

我似乎找不到在任何地方都可以找到user.config路径的部分,在我看来,就像您指定自己的user.config文件和您自己的路径一样.也许我错了...

根据我的特定需求,您能为我指出有关您的代码的正确方向吗?

再次感谢您与我分享您的精彩文章!
Hi.

Thanks for sharing this with me!!

I probably should have mentioned that I''m pretty new to C# (and to computer programming in general) so to be honest I don''t fully understand everything you have done in your project.

I can''t seem to find the part where you get the user.config path anywhere, it looks to me like you specify your own user.config file, and your own path. Maybe I''m wrong......

Could you, based on my specific needs, point me in the right direction regarding your code?

Again, thanks for sharing your great article with me!


这篇关于访问另一个应用程序的"user.config".文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆