示例#1
0
 public void saveFile(Person[] people) {
   System.IO.FileStream file;
   SaveFileDialog d = new SaveFileDialog();
   d.Filter = "Text | *.txt";
   d.FilterIndex = 1;
   d.Title = "Save Data As";
   d.OverwritePrompt = false;
   if(d.ShowDialog() == DialogResult.OK)
     file = (System.IO.FileStream)d.OpenFile();
   else
     return;
   for(int k = 0; k < people.Count();k++) {
     String x = "\n" + people[k].currentNode.toString() + " " + people[k].destinationNode.toString() + "\n";
     byte[] line = new UTF8Encoding(true).GetBytes(x);
     file.Write(line, 0, line.Length);
     for(int j = 0; j < people[k].path.Count;j++) {
       line = new UTF8Encoding(true).GetBytes(people[k].path[j].toString() + " \n");
       file.Write(line, 0, line.Length);
     }
     line = new UTF8Encoding(true).GetBytes("\n\n");
   }
   file.Close();
 }