设置ini文件中的值. [英] Setting values in ini file....

查看:58
本文介绍了设置ini文件中的值.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

查看一些代码,发现我没有设置握手,奇偶校验或StopBits
在文件中,所以我进去发现我正在设置所有简单的参数,例如Baudrate,Databits.我是需要Name.Value的人,即:

Hi All,

Going over some code and found I wasn''t setting the Handshake, Parity or StopBits
in the file so I went in and found I was setting all the easy ones like Baudrate, Databits. I was the ones which require Name.Value ie:

myComPort.Databit = 8;


很好,


fine,

myComPort.Handshake = Handshake.None


我不是.这些值是枚举,不是吗?
所以我尝试了


I wasn''t. Those values are enums aren''t they?
So I tried

myComPort.Handshake =Handshake.Enum.Parse(typeof(Handshake)(ITEMhandshake));


不,它没有用,有没有办法做到这一点?

格伦
问题中的ini是:
董事会汇率= 2400
奇偶校验=无
DATABITS = 8
STOPBITS =一个
握手=无

而且我知道BOARDRATE应该是BAUDRATE.


and no, it didn''t work, there is a way to do this isn''t there?

Glenn
The ini in Question is:
BOARDRATE = 2400
PARITY = None
DATABITS = 8
STOPBITS = One
HANDSHAKE = None

and I know BOARDRATE should be BAUDRATE.

推荐答案

您可以
myComport.Handshake = (Handshake)Enum.Parse(typeof(Handshake), "None");



将"None"替换为从ini文件中读取的字符串.



Replace "None" with the string that you read out of your ini file.


这篇关于设置ini文件中的值.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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