Microscopic Traffic Simulator
FileDataStore.cs
Go to the documentation of this file.
1 
2 using System.IO;
4 {
9  {
13  private string path;
14 
19  internal FileDataStore(string path)
20  {
21  this.path = path;
22  }
23 
29  internal StreamWriter GetStreamWriter()
30  {
31  string path = this.path;
32  if (File.Exists(path))
33  {
34  int suffixNumber = 1;
35  do
36  {
37  string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(this.path);
38  fileNameWithoutExtension += "_" + suffixNumber;
39  path = Path.GetDirectoryName(this.path) + fileNameWithoutExtension + Path.GetExtension(this.path);
40  suffixNumber++;
41  } while (File.Exists(path));
42  }
43 
44  return new StreamWriter(path);
45  }
46  }
47 }
Class for storing line data to text files.
Definition: FileDataStore.cs:8