private static int getID() { //read new id from file and return it // 100 is Base id int id; if (File.Exists("id.txt")) { TextReader tr = new StreamReader("id.txt"); id = Int32.Parse(tr.ReadLine()); id++; tr.Close(); File.WriteAllText(@"id.txt", string.Empty); TextWriter tw = new StreamWriter("id.txt"); tw.WriteLine(id); tw.Close(); } else { id = 100; TextWriter tw = new StreamWriter("id.txt"); tw.WriteLine(id); tw.Close(); } return id; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)