我想要实现的非常简单:我有一个Windows窗体(.NET 3.5)应用程序,它使用一个路径来读取信息.用户可以使用我提供的选项表单修改此路径.
现在,我想将路径值保存到文件中供以后使用.这将是保存到此文件的众多设置之一.该文件将直接位于应用程序文件夹中.
我理解有三种选择:
我读到.NET配置文件没有预见到将值保存回来.至于注册表,我想尽可能远离它.
这是否意味着我应该使用自定义XML文件来保存配置设置?如果是这样,我希望看到代码示例(C#).
我已经看过关于这个问题的其他讨论,但我仍然不清楚.
好吧,我知道有很多问题,但它们都来自很久以前.
所以.我知道这是可能的,因为地图应用程序可以做到这一点.
在地图应用程序中,如果我关闭此应用程序的本地化,它会向我发送一条消息,如果我按好,"设置应用程序"将打开.我的问题是,这怎么可能?如何从我自己的应用程序中打开"设置应用程序"?
基本上我需要做同样的事情,如果用户关闭我的应用程序的位置,那么我会给他一条消息,说明会打开"设置应用程序"
我有一个使用C#在VS2010中编写的Windows窗体应用程序,并在app.config
文件中获得以下错误:
Message 4 Could not find schema information for the attribute 'name'
Message 8 Could not find schema information for the attribute 'name'
Message 12 Could not find schema information for the attribute 'name'
Message 5 Could not find schema information for the attribute 'serializeAs'
Message 15 Could not find schema information for the element 'CCP_Utility.Settings1'
Message 2 Could not find schema information for the element 'CCP_Utility.Properties.Settings'
Message 3 Could not find schema information for the element 'setting' …
Run Code Online (Sandbox Code Playgroud) 我在我的项目中添加了App.config文件.我从Project> Properties> Settings面板创建了两个设置 -
我注意到当我添加设置时,我可以将范围定义为User
或Application
.-
如果我定义设置,因为User
它转到userSettings
部分,
如果我定义设置,因为Application
它转到applicationSettings
部分
App.config中
<configuration>
<userSettings>
<DemoApp.Properties.Settings>
<setting name="MySetting1" serializeAs="String">
<value>Value1</value>
</setting>
</DemoApp.Properties.Settings>
</userSettings>
<applicationSettings>
<DemoApp.Properties.Settings>
<setting name="MySetting2" serializeAs="String">
<value>Value2</value>
</setting>
</DemoApp.Properties.Settings>
</applicationSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
但是,这些设置可以通过相同的方式访问.cs
-
码
string mySetting1 = DemoApp.Properties.Settings.Default.MySetting1;
string mySetting2 = DemoApp.Properties.Settings.Default.MySetting2;
Run Code Online (Sandbox Code Playgroud)
在这两者之间应该选择的范围User
和Application
范围之间有什么区别?
我想在我的应用程序的设置包中包含应用程序版本和内部修订,例如1.0.1(r1243).
Root.plist文件包含这样的片段......
<dict>
<key>Type</key>
<string>PSTitleValueSpecifier</string>
<key>Title</key>
<string>Version</string>
<key>Key</key>
<string>version_preference</string>
<key>DefaultValue</key>
<string>VersionValue</string>
<key>Values</key>
<array>
<string>VersionValue</string>
</array>
<key>Titles</key>
<array>
<string>VersionValue</string>
</array>
</dict>
Run Code Online (Sandbox Code Playgroud)
我想在构建时替换"VersionValue"字符串.
我有一个脚本可以从我的存储库中提取版本号,我需要的是一种在构建时处理(预处理)Root.plist文件的方法,并替换版本号而不影响源文件.
在大型复杂的软件产品中,管理可配置设置成为一个主要的痛苦.我见过这个问题的两种方法是:
这些方法对我来说都是错的.
是否有可用于简化问题的设计模式?也许会利用依赖注入技术的东西.
configuration design-patterns configuration-files application-settings
我必须在iPhone设置中获取当前国家/地区.谁能告诉我如何在iPhone应用程序中获取当前国家/地区.
我必须使用当前国家来解析我需要通过当前国家/地区的RSS源.
请帮我找到这个国家.
提前致谢.
我有一个应用程序,我只是迁移到Azure.目前我使用web.config转换来管理更改数据库连接字符串dev/staging/prod环境.如何在Azure中管理这些多个连接字符串?
connection-string azure application-settings staging azure-sql-database
给出一个"标准"弹簧启动应用程序@RestController
,例如
@RestController
@RequestMapping(value = "foo", produces = "application/json;charset=UTF-8")
public class MyController {
@RequestMapping(value = "bar")
public ResponseEntity<String> bar(
return new ResponseEntity<>("Hello world", HttpStatus.OK);
}
}
Run Code Online (Sandbox Code Playgroud)
有没有阻止端点开始的注释或技术可言,如果/除非某个应用程序属性存在/不存在.
注意:测试方法内的属性并且爆炸不是解决方案,因为端点将存在.
我不关心粒度:即只启用/禁用方法或整个类都很好.
由于配置文件不是属性,因此通过配置文件进行控制并不能解决我的问题.
有没有办法从不同的项目访问设置文件?例如,我有一个包含2个项目的解决方案(让我们称之为Proj1和Proj2).我想从Proj1中的Program.cs访问Proj2的应用程序设置.这可能吗?
c# ×4
iphone ×3
appsettings ×2
ios ×2
objective-c ×2
winforms ×2
.net ×1
app-config ×1
azure ×1
java ×1
spring ×1
spring-boot ×1
staging ×1
xcode ×1
xml ×1