从 exe.config 读取appSettings 中的配置数据
右键解决方案,添加引用--> System.Configuration.dll
在exe.config 中添加数据
<appSettings>
<add key="IP" value="0.0.0.0" />
<add key="Port" value="" />
</appSettings>
读取添加的配置数据
if ((true == IPAddress.TryParse(ConfigurationManager.AppSettings["IP"], out IPAddress alarmIP))&& (true == int.TryParse(ConfigurationManager.AppSettings["Port"], out int alarmPort)))
{//有外部配置,用外部配置指定地址
jTudpt = new JTudpt("UDP", alarmIP.ToString(), alarmPort);
}
else
{//无外部配置,用默认地址和端口
jTudpt = new JTudpt("UDP", "0.0.0.0", );//服务器
}
从 exe.config 读取appSettings 中的配置数据的更多相关文章
- SpringBoot读取yml中的配置,并分离配置文件
前言 在项目中经常遇到需要读取配置文件中的配置信息,这些配置信息之所以不写在代码中是因为实际项目发布或者部署之后会进行更改,而如果写在代码中编译之后没有办法进行修改. 之前使用的是properties ...
- .Net Core 读取appsettings.json的配置
在.net core中是没有*.config 文件的 配置文件都是*.json 1.在project.json里下面这行代码 "Microsoft.Extensions.Options.Co ...
- 接口测试中读取excel中的请求数据含有中文问题,UnicodeEncodeError: 'latin-1' codec can't encode character '\u5c0f' in position
错误信息:UnicodeEncodeError: 'latin-1' codec can't encode character '\u5c0f' in position 31: Body ('小') ...
- .net core 中如何读取 appsettings.json 相关配置
appsettings.json如下 { "Logging": { "LogLevel": { "Default": "Debug ...
- ASP.NET CORE读取appsettings.json的配置
如何在appsettings.json配置应用程序设置,微软给出的方法:https://docs.microsoft.com/en-us/aspnet/core/fundamentals/config ...
- java中java.exe,javac 在editplus中的配置
java.exe,javac设置快捷键(editplus) 1.tools-preferences 2.add tools---program java关键字
- 读取Assets中的文件数据
try { // 返回的字节流 InputStream is = getResources().getAssets().open("info.txt"); // 当读取时,属于文本 ...
- python读取es中的所有数据并计算md5然后进行持久化
#!/usr/bin/python import threading import json import time from elasticsearch import Elasticsearch f ...
- 使用python读取文本中结构化数据
需求 read some .txt file in dir and find min and max num in file. solution: echo *.txt > file.name ...
随机推荐
- DFT
离散傅里叶变换(Discrete Fourier Transform,缩写为DFT),是傅里叶变换在时域和频域上都呈离散的形式, 将信号的时域采样变换为其DTFT的频域采样.在形式上,变换两端(时域和 ...
- 139. Word Break (String; DP)
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separa ...
- ECMAScript6新特性之Reflect
一 Reflect.ownKeys()获取对象属性. 可枚举的.不可枚举的.自有的.继承的. let fruit = { '2' : 'mango', [Symbol.for('pink')] : ' ...
- [leetcode]238. Product of Array Except Self除了自身以外的数组元素乘积
Given an array nums of n integers where n > 1, return an array output such that output[i] is equ ...
- DataTable的序列化和反序列化
/// <summary> /// DataTable序列化 /// </summary> /// <param name="dt"></ ...
- js-移动端android浏览器中input框被软键盘遮住的问题解决方案
我遇到的问题:在一个页面里有一个弹出层之前我给我的最外层加了固定定位 用了下面的方法也不好使:没有办法我将之改为绝对定位层级变高在加上一个顶部标签通过js计算顶部高度来实现满屏遮挡: <sect ...
- Golang之redis
redis是个开源的高性能的key-value的内存数据库,可以把它当成远程的数据结构. 支持的value类型非常多,比如string.list(链表).set(集合). hash表等等 redis性 ...
- Linux 添加硬盘
一.简介 本文介绍为Linux 添加硬盘的基本方法,同时适用于为虚拟机添加硬盘的情况. 二.添加小于2T的硬盘 1)分区 fdisk /dev/hda 2)建立文件系统 3)设置开机自动挂载磁盘 ...
- 什么是@guid
我将给大家讲解史上最通俗一同guid与ID的区别...
- 自然语言处理--中文文本向量化counterVectorizer()
1.载入文档 #!/usr/bin/python # -*- coding: utf-8 -*- import pandas as pd import re import jieba from skl ...