winform读写.ini文件 |
作者:管理员 来源:本站 浏览次数:2121 发布时间:2014-12-5 13:30:27 |
1、在头部引用 [DllImport("kernel32")] private static extern long WritePrivateProfileString(string section, string key,string val,string filePath); [DllImport("kernel32")] private static extern int GetPrivateProfileString(string section, string key,string def, StringBuilder retVal, int size,string filePath);
WritePrivateProfileString("Setup","UserName",userno.Text,Application.StartupPath "\\mcs.ini"); 3、读取.ini StringBuilder temp = new StringBuilder(255); int i = GetPrivateProfileString("Setup","UserName","",temp,255, Application.StartupPath "\\mcs.ini"); userno.Text = temp.ToString(); |