I have found some code that looks like something I would like to use but am really unsure of where it goes within the form.

The code is here.

It's the first bit of code the class INIFile section that I don't know the placement for on my form.

I use SharpDevelop for coding if this helps.

Kind regards..,

MT ;)

Hi there,
The link you provided, shows a Class named INIFile...
So in order to use that code, you should create a new Class file in your project(Dont know how its is done in SharpDevelop :p ), delete every text in the file, and paste this code. Since you have done that, i think that you know how to use the class..

Happy .ini file reading,
Alex :)

Finally got it to work like this:-

using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;

namespace Ini
	/// <summary>
	/// Create a New INI file to store or load data
	/// </summary>
	public class INIFile

        private string filePath;
        private static extern long WritePrivateProfileString(string section,
        string key,
        string val,
        string filePath);

        private static extern int GetPrivateProfileString(string section,
        string key,
        string def,
        StringBuilder retVal,
        int size,
        string filePath);
        public INIFile(string filePath)
            this.filePath = filePath;

        public void Write(string section, string key, string value)
            WritePrivateProfileString(section, key, value.ToLower(), this.filePath);

        public string Read(string section, string key)
            StringBuilder SB = new StringBuilder(255);
            int i = GetPrivateProfileString(section, key, "", SB, 255, this.filePath);
            return SB.ToString();
        public string FilePath
            get { return this.filePath; }
            set { this.filePath = value; }

and then putting:-

using Ini;

at the top of my main form.


MT ;)