大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> NET专区 -> INI文件的操作(ASP.NET+C#)

INI文件的操作(ASP.NET+C#)

时间: 2021-07-31 作者:daque

(一)inifile.csusing system;using system.runtime.interopservices;using system.text;namespace createwebdir{ /// <summary> /// inifile 的纲要证明。 /// </summary> public class inifile { public string path; public inifile(string inipath) { path = inipath; } [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); public void iniwritevalue(string section,string key,string value) { writeprivateprofilestring(section,key,value,this.path); } public string inireadvalue(string section,string key) { stringbuilder temp = new stringbuilder(255); int i = getprivateprofilestring(section,key,"",temp, 255, this.path); return temp.tostring(); } }}=======================================================(二)运用示例 string inifile = @"d:\bug2000.ini"; if (!file.exists(inifile)) { using (filestream fs = file.create(inifile)) { fs.close(); } } inifile myini = new inifile(inifile); for(i=0;i<args.length;i++) { myini.iniwritevalue("webdir","arg"+i.tostring(),args[i]); }

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.