简体   繁体   English

如何确定正在使用哪个C#设置文件

[英]How to Determine Which C# Settings File Is Being Used

The Settings.settings file that's part of my C# application has the following User entry. 作为C#应用程序一部分的Settings.settings文件具有以下“ User条目。 It is called selected_device_idx; 它称为selected_device_idx; is an int ; 是一个int ; and its value is set to -1. 并将其值设置为-1。

Yet, during startup, when I fetch this value, it is set to another value, 5. 但是,在启动期间,当我获取此值时,它将设置为另一个值5。

I am using this to fetch the value 我正在用它来获取价值

int temp_selected_device_idx = (int)Properties.Settings.Default["selected_device_idx"];

How can I determine where the origin of this entry? 如何确定此条目的来源?

I am reposting @HansPassant 's comment as the answer. 我将@HansPassant的评论重新发布为答案。 sz Now, I have to find out why the settings are not holding on a non-development workstation, where I am installing this application. 现在,我必须找出为什么设置未保存在我要安装此应用程序的非开发工作站上的原因。

Hans, Thanks for the comment. 汉斯,谢谢你的评论。

Well, if 5 isn't the default value then it comes from a user.config file. 好吧,如果5不是默认值,那么它来自user.config文件。 It is hard to find back because it is stored in a AppData directory with a strange name. 很难找到它,因为它以奇怪的名称存储在AppData目录中。 If you can't find it then SysInternals' Process Monitor can show you. 如果找不到,则SysInternals的Process Monitor可以显示给您。 Or just write back whatever value you want and Save() it. 或者只是写回您想要的任何值,然后将其保存()。 – Hans Passant yesterday –昨天的汉斯·帕桑(Hans Passant)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM