Re: Trouble with a Ini Class
just as a note lines 2&3 are just for trouble shooting to show that i can write a value
they will be removed in the actuall code
Re: Trouble with a Ini Class
Can really see why one would act different then another maybe post the code for the readString method.
Re: Trouble with a Ini Class
VB Code:
IniFile ini = new IniFile(@"\\filervoca\groups\edit\public\iPass\Billpass config\billpass25.ini");
//ini.Write("Info", "Department", "PR AD CI GC MK ED FI IT HR DC UW UN");
//ini.Write("Section1", "KeyString", "PR AD CI GC MK ED FI IT HR DC UW UN");
ini.IniWriteValue("Section1", "KeyTest", @"c:/test.txt");
string str = ini.IniReadValue("Section1", "KeyString");
string tem = ini.IniReadValue("Section1", "KeyTest");
department = str.Split(' ');
Here is the Class
VB Code:
namespace Ini
{
/// <summary>
/// Create a New INI file to store or load data
/// </summary>
public class IniFile
{
public string path;
[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);
/// <summary>
/// INIFile Constructor.
/// </summary>
/// <param name="INIPath"></param>
public IniFile(string INIPath)
{
path = INIPath;
}
/// <summary>
/// Write Data to the INI File
/// </summary>
/// <param name="Section"></param>
/// Section name
/// <param name="Key"></param>
/// Key Name
/// <param name="Value"></param>
/// Value Name
public void IniWriteValue(string Section,string Key,string Value)
{
WritePrivateProfileString(Section,Key,Value,this.path);
}
/// <summary>
/// Read Data Value From the Ini File
/// </summary>
/// <param name="Section"></param>
/// <param name="Key"></param>
/// <param name="Path"></param>
/// <returns></returns>
public string IniReadValue(string Section,string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section,Key,"",temp,255,this.path);
return temp.ToString();
}
}
}
Re: Trouble with a Ini Class