ini file

  • Thread starter Thread starter Sphinx
  • Start date Start date
S

Sphinx

Hi

I'm trying to make a project where I have to read from an ini file the keys
and values of several sections.
example:
[Section 1]
key1 = ala-lab
key2 = ala-amf
key3 = ala-ima

[Section 2]
key1 = ci-rep
key2 = ci-rdl
key3 = ci-rep

....

Does anyone know how to do this? I really don't have any idea.

tia,
Sphinx
 
This may help you

[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);

[DllImport("kernel32")]

private static extern int SearchPath(string path,

string fileName,string fileExt,int bufSize, StringBuilder buffer,

string filePart);

[DllImport("kernel32")]

private static extern int GetLastError();



You will find a ton of implementations around INI files If you search the
opersource or community sites, (www.codeproject.com example)

Hope it helps

henk
 
If you're not familiar with using API calls, you can also the StreamReader
and StreamWrite objects to open and read the text files. You can then use
the various text parsing methods to search for the section headings and
locate values by parsing the text file.

--
Gerry O'Brien
Visual Developer .NET MVP



Henk Verhoeven said:
This may help you

[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);

[DllImport("kernel32")]

private static extern int SearchPath(string path,

string fileName,string fileExt,int bufSize, StringBuilder buffer,

string filePart);

[DllImport("kernel32")]

private static extern int GetLastError();



You will find a ton of implementations around INI files If you search the
opersource or community sites, (www.codeproject.com example)

Hope it helps

henk

Sphinx said:
Hi

I'm trying to make a project where I have to read from an ini file the keys
and values of several sections.
example:
[Section 1]
key1 = ala-lab
key2 = ala-amf
key3 = ala-ima

[Section 2]
key1 = ci-rep
key2 = ci-rdl
key3 = ci-rep

...

Does anyone know how to do this? I really don't have any idea.

tia,
Sphinx
 
Back
Top