在ini文件中读取软件版本号
来源:互联网 发布:excel视图宏数据标签 编辑:程序博客网 时间:2024/06/05 16:03
1 先新建一个.ini文件,内容如下:
2 引用
using System.Runtime.InteropServices;//引用命名空间
3 读取文件内容
新建
加入引用
//读取.ini文件 [DllImport("kernel32")] private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retval, int size, string filePath); private string strFilePath = Application.StartupPath + "\\softVersion.ini";//获取INI文件路径,放在debug文件 private string strSec = ""; //INI文件名
调用
//读取INI文件中的版本号 if (File.Exists(strFilePath))//读取时先要判读INI文件是否存在 { //读取文件名 strSec = Path.GetFileNameWithoutExtension(strFilePath); textBox_softVersion.Text = ContentValue(strSec, "softVersion"); } else { MessageBox.Show("INI文件不存在,无法读取标准软件版本"); }
...
其中的方法:
private string ContentValue(string Section, string key) { StringBuilder temp = new StringBuilder(1024); GetPrivateProfileString(Section, key, "", temp, 1024, strFilePath); return temp.ToString(); }
...
别忘记加using System.IO
...
阅读全文
0 0
- 在ini文件中读取软件版本号
- Delphi中读取INI文件
- 在VC程序下读取INI文件
- 读取软件版本号
- MFC中读取和写ini文件
- 读取文档-写入ini文件中
- 如何在.Net的C#中制作DLL文件,读取ini文件
- Ini文件读取类
- 读取Ini文件
- java读取ini文件
- 读取INI文件
- vc读取ini文件
- c#读取ini文件
- c#读取ini文件
- ini文件读取(C#)
- 读取INI文件
- ini文件读取
- 读取INI文件
- Non-decreasing Array
- react+redux+react-router4配置过程
- QSplashScreen
- MVC, MVP, MVVM比较以及区别
- 个人关于转载博文的建议和承诺
- 在ini文件中读取软件版本号
- VMware10安装CentOS6.5,并开启远程XShell连接
- Redis的使用场景介绍
- Ubuntu环境变量的查看与设置
- LeetCode-28-Implement strStr() KMP模板题
- Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured
- 给js文件传参数
- IDEA破解 2017 IDEA license server激活
- 计算两个经纬度的距离