So when it comes to time to save it, read the folder it is going to, and look at tahe names:
string[] paths = Directory.GetFiles(@"D:\Temp\", @"file*.txt");
You can then work out the highest current number from that:
int max = 0;
foreach (string path in paths)
{
string justTheName = Path.GetFileNameWithoutExtension(path);
Match m = Regex.Match(justTheName, @"\d+$");
if (m.Success)
{
int i = int.Parse(m.Value);
max = Math.Max(max, i);
}
}
string newFileName = string.Format(@"D:\Temp\file{0}.txt", max + 1);