在线请教:用C#如何创建INI文件啊??

cherish 2002-12-06 04:10:35
如题
...全文
543 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
cherish 2002-12-06
  • 打赏
  • 举报
回复
这么复杂啊,看不懂啊。是创建schema.ini.导入TXT文本所需要生成的文件。
stdao 2002-12-06
  • 打赏
  • 举报
回复
http://www.zdnet.com.cn/developer/code/story/0,2000081534,39065664-2,00.htm
http://developer.ccidnet.com/pub/disp/Article?columnID=294&articleID=26002&pageNO=1
希望对你有所帮助
suzhan 2002-12-06
  • 打赏
  • 举报
回复
string path = Application.StartupPath ;

Ini ini = new Ini(path+"\\Set.ini");

ini.IniWriteValue ("Main","Form String","Something");

存储当前目录下的ini文件,如没有则创建!
suzhan 2002-12-06
  • 打赏
  • 举报
回复
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;

namespace MyClock
{
/// <summary>
/// Ini 的摘要说明。
/// </summary>
public class Ini
{

public string path; //INI文件名


public Ini(string INIPath)
{
//
// TODO: 在此处添加构造函数逻辑
//
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);

//声明读写INI文件的API函数




public void IniWriteValue(string Section,string Key,string Value)

{

WritePrivateProfileString(Section,Key,Value,this.path);

}

//写INI文件

public string IniReadValue(string Section,string Key)

{

StringBuilder temp = new StringBuilder(255);

int i = GetPrivateProfileString(Section,Key,"",temp,255,this.path);

return temp.ToString();

}

//读取INI文件指定
}
}

111,125

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧