我想用Visual Studio 2005 的C#编写一个名为"desktop.ini"的文件,需要按照以下的格式写成文件:[section1]
key1=value1
[section2]
key2=value2
key3=value3在网上我搜索了很多关于读写INI文件的内容,但是[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);函数里面只能重载4个参数,如果想写上面的内容的话需要6个参数,在这里我迷糊了,请求指点,谢谢。

解决方案 »

  1.   

    4个参数不够你用啊?一个section循环一次加key=value
    直到写完为止
      

  2.   

    不知道你所说的需要6个参数怎么来的
    WritePrivateProfileString("section1", "key1", "value1", filename);
    WritePrivateProfileString("section2", "key2", "value2", filename);
    WritePrivateProfileString("section2", "key3", "value3", filename);
    这样写不就行了?