搜索
查看
编辑修改
首页
UNITY
NODEJS
PYTHON
AI
GIT
PHP
GO
CEF3
JAVA
HTML
CSS
搜索
weixin_40725706
这个屌丝很懒,什么也没留下!
关注作者
热门标签
article
热门文章
1
Docker | Docker+Nginx部署前端项目
2
【毕业设计】深度学习车道线检测与识别系统 - python 机器视觉_车道线检测系统设计与开发
3
Java Web3J :使用web3j调用自己的智能合约,返回一个内部有数组的对象结构时出现NPE问题
4
【不忘初心】Win10_2004.19041.329_X64_七合一_[纯净精简版](2020.06.18)
5
【wsl安装失败】This update only applies to machines with the windows Subsytem for Linux
6
【docker】WSL+docker_desktop+GPU配置环境失败_nvidia-container-cli: initialization error: wsl en
7
【segment-anything】- Meta 开源万物可分割 AI 模型
8
Golang GUI编程-图形化界面库简介_golang图形化界面
9
MacBook安装Golang Oracle数据库驱动程序_“libclntsh.dylib.19.1”不是来自app store的app。
10
python文件(概念、基本操作、常用操作、文本文件的编码方式)
当前位置:
article
> 正文
config文件读写_po项目 config
作者:weixin_40725706 | 2024-02-15 11:14:26
赞
踩
po项目 config
以下设置为vs2008或以上
1. 向项目添加app.config文件:
右击项目名称,选择“添加”→“添加新建项”,在出现的“添加新项”对话框中,选择“添加应用程序配置文件”;如果项目以前没有配置文件,则默认的文件名称为“app.config”,单击“确定”。出现在设计器视图中的app.config文件为:
<?xmlversion="1.0"encoding="utf-8" ?>
<configuration>
</configuration>
注意:非web程序默认为app.config,web项目默认为web.config.
2.配置文件内容格式:(app.config)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="path" value="c:\\system32"/>
</appSettings>
</configuration>
3.读取配置(配置文件为app.config或者web.config看项目而定):
using System.Configuration;
string filepath = ConfigurationManager.AppSettings["path"]
表示从.config中定义的类似这样的<add key="path" value="c:\\system32"/>读取值,c:\\system32
4.写入配置
Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
cfa.AppSettings.Settings["path"].Value = "c:\\system32";
cfa.Save();
ConfigurationManager.RefreshSection("appSettings"); //立即更新,因为有缓存
5.添加名字空间
想调用ConfigurationManager必须要先在工程里添加system.configuration.dll程序集的引用。
在解决方案管理器中右键点击工程名称,在右键菜单中选择添加引用,.net TablePage下即可找到
6.修改配置文件注意事项
对于web程序,修改了web.config会导致整个webapplication的重启,session和cookie也会无效,需要严重注意!
所以如需经常修改就不要保存在根目录下的web.config下了。
7.访问自定义节点
自定义的节点要通过ConfigurationManager.GetSection()来读取,得先在配置文件中设置自定义节点的信息,如下:
<configSections>
<sectionGroup name="TestGroup">
<section name="Test" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
这段代码需要放在appSettings之前,否则会出错。然后就可以添加自定义的节点了.
<TestGroup>
<Test>
<add key="test1" value = "king"/>
<add key="test2" value = "jim"/>
</Test>
</TestGroup>
a.在代码中读取这些节点
using System.Collections.Specialized;
NameValueCollection config = (NameValueCollection)ConfigurationManager.GetSection("TestGroup/Test");
使用config["test1"]就能获得value值.NameValueCollection是在System.Collections.Specialized命名空间下的.这些节点的配置在Web.Config中也是一样的
b.在代码中更新这些节点(config["test1"]="值一"会报read only错误)
NameValueCollection setting = new NameValueCollection();
string strkey = PrintSetting_Str.Enable.ToString();
string strvalue = needsaving.benable.ToString();
setting.Set(strkey, strvalue);
//保存
strkey = PrintSetting_Str.Printlabel.ToString();
XmlDocument xmldoc = new XmlDocument();
XmlElement rootElement = xmldoc.createElement_x(strkey);
const string perfix = "add";
const string keyatt = "key";
const string valueatt = "value";
foreach (string item in setting.AllKeys)
{
XmlElement newelem = xmldoc.createElement_x("", perfix, "");
XmlAttribute att = xmldoc.CreateAttribute(keyatt);
att.Value = item;
newelem.SetAttributeNode(att);
att = xmldoc.CreateAttribute(valueatt);
att.Value = setting[item];
newelem.SetAttributeNode(att);
rootElement.A(newelem);
}
xmldoc.A(rootElement);
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.Sections[strkey].SectionInformation.SetRawXml(xmldoc.OuterXml);
config.Save();
声明:
本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:
https://www.wpsshop.cn/blog/article/detail/84029
推荐阅读
article
centos7
配置
cuda
+
mxnet
+
jupyter
+pytorch+tensorflow1.14_please
install
the
`pkg-
config
` utility and
the
x.
目录1.安装wget2.安装anaconda3.安装nvidia驱动+
cuda
+cudnn3.1安装显卡驱动3.2安装
cuda
3.3安装cudnn4.安装pip5.安装
mxnet
6.处理matplotlib7.安装pytorch8.安装te...
[详细]
赞
踩
article
Pycharm
(
Community
版本)和
Python
3.9.0的
安装
与配置2020-10-26_
pycharm
config
or
installation
Pycharm
(
Community
版本)
安装
PyCharm是一种功能强大的
Python
编辑器,具有跨平台性。1、下载
Pycharm
,可以直接到官网下载(根据需求选择professional或community版本),或者在软件商城(一般是c...
[详细]
赞
踩
article
git
配置_
git
config
host
设置
git
user.name和user.email首先进入当前用户的Home目录,在各个系统上分别是:#WindowsC:\Users\用户名\#Linux/home/用户名~#MacOSX/Users/用户名~查看是否存在.
git
conf...
[详细]
赞
踩
article
linux
/mac vim (
config
file
/
hosts
)
的
使用快捷键之
删除
、
复制
、
粘贴
_
config
里那个文件是快捷命令键
注:以下
删除
、
复制
和
粘贴
均是在非编辑模式下
的
操作(esc)一、
删除
x小写
的
x表示向后
删除
一个字符,也就是
删除
光标所在字符nxn表示数字,表示向后
删除
每个字符,例如:10x表示
删除
包括光标在内
的
后面10个字符X大写
的
X表示
删除
光标前
的
一个字符...
[详细]
赞
踩
article
VS
Code
insiders 连接远程服务器的坑(杂记)_can'
t
open
user
config
file
1: no
such
file
or
dir
sshins
t
alla
t
ionno
t
foundVS
Code
remo
t
edevelopmen
t
t
oolerr
or
-AnSSHins
t
alla
t
ioncouldn'
t
befoundh
t
t
ps://frederick-s.gi
t
hub.io/20...
[详细]
赞
踩
article
E212: Can't
open
file
for
writing
_~/.
docker
/
config
.
json
"
e212
: can't
open
file
for w
原因分析:一般都是因为一次创建了文件夹同时创建了文件导致,vi/etc/
docker
/demo.
json
解决方案:手动先进入etc目录下:cd/etc/手动创建文件夹
docker
:mkdir
docker
/进入
docker
:cd
docker
/...
[详细]
赞
踩
article
Elasticsearch
学习<一>安装
Elasticsearch
_
mount
/
m
y
data
/
elasticsearch
/
config
/
elasticsearch
.
y
test_
mount
/
m
y
data
/
elasticsearch
/
config
/
elasticsearch
.
y
ml:/usr/share/elasticsearc
mount
/
m
y
data
/
elasticsearch
/
config
/elasti...
[详细]
赞
踩
article
拦截器
配置,
FeignClient
根据业务规则实现微服务动态路由_@
feignclient
(
name
=
"
upi-
security
-
server
"
,
config
OpenFeign是一个基于Java的声明式HTTP客户端,它简化了编写基于HTTP的API的代码。它使用了注解来定义和配置HTTPAPI,并且自动地将这些API转换为相应的HTTP请求。OpenFeign的特点包括:声明式API:使用Ja...
[详细]
赞
踩
article
thinkphp6
接入阿里云短信实战和踩坑_
class
'
darabonba
\
openapi
\
models
\
config
' not found
下载完之后随便你放哪里,但是要在你当前使用版本的php.ini中的配置一下正确的引用路径,在curl.cainfo后添加路径:curl.cainfo="D:\phpcacert\cacert.pem"这里注意一下流程:买完短信服务包后,需要...
[详细]
赞
踩
article
MyBatis
之动态代理实现
增删
改查以及
MyBatis
-
config
.
xml
中
读取DB信息文件和
SQL
中
JavaBean
别名配置
MyBatis
动态代理实现
增删
改查
MyBatis
-
config
.
xml
中
读取DB信息文件
SQL
中
JavaBean
别名配置
MyBatis
之动态代理实现
增删
改查以及
MyBatis
-
config
.
xml
中
读取DB信息文件和
SQL
中
JavaBean
...
[详细]
赞
踩
article
Docker
启动
错误_
docker
启动
koko
报错 not
found
file
:
config
.yml
Failedtoopen/createtheinternalnetwork'HostInterfaceNetworking-VirtualBoxHost-OnlyEthernetAdapter#2’(VERR_INTNET_FLT_IF_N...
[详细]
赞
踩
article
docker
config
【
docker
配置】_
docker
exec
-
opts
$cat/etc/
docker
/daemon.json{"
exec
-
opts
":["native.cgroupdriver=systemd"],"data-root":"/data/
docker
","live-restore":true,"...
[详细]
赞
踩
article
如何关闭
vue
cli2的
useEslint
是否设置语法检查_
vue
2
babel
.
config
.js
useeslint
在项目下面的
config
文件夹下面的index.js的第26行有一个
useEslint
:true改成false即可_
vue
2
babel
.
config
.js
useeslint
vue
2
babel
.
config
.js
useeslint
在项目下面的...
[详细]
赞
踩
article
ATSHA204A
(三)——
config
区
配置
_
atsha204a
lock
config
成功唤醒之后,才可以做很多事情,实现它的命令功能。芯片的
config
区
和data
区
一旦锁定,没有办法解锁,锁的方法只能通过
lock
command来进行锁定。
config
区
在没锁定的时候,可以使用writecommand来进行写操作,但注意...
[详细]
赞
踩
article
vue
脚手架
在
vue
.
config
.
js
文件中配置
scss
全局变量
_
vue
.
config
.
js
scss
经常会听到这样的玩笑,如果你不学习css预处理语言,当老板让你修改所有界面的颜色的时候不累死你说者无意听者有心,那怎么能实现一个修改一个变量所有页面的颜色都发生变化呢今天就使用
vue
中的
scss
作为例子首先我们还是有一个提前建立好的
vue
脚...
[详细]
赞
踩
article
vue
.
config
.js配置
sass
-
resources
-
loader
_
vue
.
config
.js
sass
-
loader
配置
sass
-
resources
-
loader
详细查看
sass
-
resources
-
loader
的GitHub网站新建
vue
.
config
.js文件开始配置内容//scss-
resources
-
loader
配置module.exports=...
[详细]
赞
踩
article
Error:Configuration with
name
'
default
'
not
found
.解决方案_
default
config
not
found
for application
config
今天导入github上的一个项目ElmBusiness时报如下的错误:Configurationwith
name
'
default
'
not
found
经过查阅资料,是因为gradle的配置出现错误,这个项目自己按照如下办法成功解决:1.将set...
[详细]
赞
踩
article
微信小
程序
编译每次都出现[
project
.
config
.
json
文件内容错误]
project
.
config
.
json
:
libVersion
字段需为
string
微信开发者工具——检查更新。千万不要手贱打钩,会更新到预发布版本,因为他最新。在manifest.
json
中加入以下代码。_[
project
.
config
.
json
文件内容错误]
project
.
config
.
json
:libversion字...
[详细]
赞
踩
article
vite
.
config
.
js
配置入门与小记
1如何创建
vite
项目?step1:npminit
vite
@latestyarncreate
vite
step2:npminit
vite
@latestmy-vue-app--templatevuenpm7+,需要额外的双横线:npminitv...
[详细]
赞
踩
article
vit
e
.
config
.
js
里面使用
环境变量
_如何在
vit
e
.
config
.
js
的 proxy 中使用 import.meta.
env
.
vit
文章目录一、前言二、使用步骤1.创建.
env
文件2.获取变量3.部署结果三、总结一、前言考虑到一个项目可能会有开发版本、上线版本、测试版本等等多个版本,不同的环境会有不同请求api接口,就需更改一些基本配置,基本路径,服务器代理这种都要更改...
[详细]
赞
踩
相关标签
python
git
linux
ubuntu
vscode
java
后端
elasticsearch
微服务
架构
云原生
阿里云
云计算
mybatis
docker
容器
运维
kubernets
vue
sass
1024程序员节