Hi,

I am trying to cobble together a couple of snippets that I have found on the net to read and write to an ini file.

The reading and writing part works fine but what I am trying to do now is to check if the ini file actually exists on first startup.

a snippet of my code is here:-

static void Main() 
		{
			Application.Run(new Form1());
			IniFile ini = new IniFile(System.IO.Path.Combine(Application.StartupPath, "SUsettings.ini"));
			if (ini.Exists())
            ini.Load();
else
{
 DialogResult dr = MessageBox.Show("You need to enter data, do you want to do it now?", 
                      "Data Entry", MessageBoxButtons.YesNo);
switch(dr){
   case DialogResult.No: ActiveForm.Close();
   case DialogResult.Yes: break;
}
}
		}

I get two errors:-

'Ini.IniFile' does not contain a definition for 'Exists' and no extension method 'Exists' accepting a first argument of type 'Ini.IniFile' could be found (are you missing a using directive or an assembly reference?) (CS1061)

'Ini.IniFile' does not contain a definition for 'Load' and no extension method 'Load' accepting a first argument of type 'Ini.IniFile' could be found (are you missing a using directive or an assembly reference?) (CS1061)

Any pointers to how to sort this would be great or if there is an easier way.

Kind regards..,

MT ;)

Error says that the Exists method is not a member of class IniFile.

You can verify the existence of a file using,

string path=System.IO.Path.Combine(Application.StartupPath, "SUsettings.ini");
if (System.IO.File.Exists(path))
        {

        }

Error says that the Exists method is not a member of class IniFile.

You can verify the existence of a file using,

string path=System.IO.Path.Combine(Application.StartupPath, "SUsettings.ini");
if (System.IO.File.Exists(path))
        {

        }

Thanks ;0)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.