简体   繁体   English

从.INI文件读取常量

[英]Read constants from .INI file

I want to write my connection string and other constants in a Settings.INI file. 我想在Settings.INI文件中写入连接字符串和其他常量。

My ini file: 我的ini文件:

[ConnectionString]
Con="Data Source=.;Initial Catalog=Test;Integrated Security=SSPI"

How can I read the connection string in VB.net when I need it? 需要时,如何在VB.net中读取连接字符串? In ASP.net it's all simpler with app.config. 在ASP.net中,使用app.config变得更加简单。 But I am working on windows forms. 但是我正在处理Windows窗体。

Any help would be appreciated. 任何帮助,将不胜感激。

You can use the My.Settings object in VB.NET. 您可以在VB.NET中使用My.Settings对象。 You can also use app.config in VB.NET as you would in ASP.NET. 您也可以像在ASP.NET中一样在VB.NET中使用app.config

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

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