I am creating an automation tool, to stop users messing with files, the thing is, my tool needs to work with an ini file which doesnt yet exist...

heres how i create the ini file...

String iniPath = @"C:\test.ini";
File.Create(iniPath);

that sets me up with my ini file... the thing is, its obviously blank and has no keys etc.

i need to populate it with the following information...

#redirect to production store
SDPORT=BGIT-SDIRLAUTO:4086
SDCLIENT=CTN610
private void button3_Click(object sender, EventArgs e)
    {
      const string fName = @"C:\file.txt";
      string txt = @"#redirect to production store" + Environment.NewLine +
                         @"SDPORT=BGIT-SDIRLAUTO:4086" + Environment.NewLine +
                         @"SDCLIENT=CTN610";
      if (System.IO.File.Exists(fName))
        System.IO.File.Delete(fName);
      System.IO.File.WriteAllText(@"C:\File.txt", txt);
    }

Thankyou, That was perfect!

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.