示例#1
0
 public static void SaveFile(EntryList list)
 {
     lock (File)
     {
         FileInfo TempFileInfo = new FileInfo(Environment.CurrentDirectory + Path.DirectorySeparatorChar + TempFile);
         if (TempFileInfo.Exists)
         {
             TempFileInfo.Delete();
         }
         XmlSerializer serializer = new XmlSerializer(list.GetType());
         using (FileStream stream = TempFileInfo.OpenWrite())
         {
             try
             {
                 serializer.Serialize(stream, list);
             }
             catch (IOException e)
             {
                 MessageBox.Show(e.ToString());
             }
         }
         FileInfo FileInfo = new FileInfo(Environment.CurrentDirectory + Path.DirectorySeparatorChar + File);
         if (FileInfo.Exists)
         {
             FileInfo.Delete();
         }
         TempFileInfo.MoveTo(FileInfo.FullName);
     }
 }