Beispiel #1
0
 public void ScriptSave(List<string> ScriptList, string filename)
 {
     string currentDirectory = Directory.GetCurrentDirectory();
     SaveFileDialogComment comment = new SaveFileDialogComment {
         Title = "Save Batch File",
         Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*",
         FileName = Path.Combine(this._appDataDir, filename)
     };
     DialogResult result = comment.ShowDialog();
     Directory.SetCurrentDirectory(currentDirectory);
     if ((result == DialogResult.OK) && (comment.FileName != null))
     {
         if ((this._appDataDir != "") && !this.CheckFolderChange(comment.FileName))
         {
             this._appDataDir = "";
         }
         FileStream stream = new FileStream(comment.FileName, FileMode.Create, FileAccess.Write);
         TextWriter writer = new StreamWriter(stream);
         foreach (string str2 in ScriptList)
         {
             writer.WriteLine(str2);
         }
         writer.Flush();
         stream.Close();
     }
 }
Beispiel #2
0
 public void FifoReadSave(FifoReadWrite innerRead, string deviceName)
 {
     XmlDocument document = new XmlDocument();
     SaveFileDialogComment comment = new SaveFileDialogComment {
         Filter = "WDS files (*.swc)|*.swc|All files (*.*)|*.*",
         FileName = "Read_FIFO"
     };
     if ((comment.ShowDialog() == DialogResult.OK) && (comment.FileName != null))
     {
         XmlTextWriter writer = new XmlTextWriter(comment.FileName, Encoding.UTF8) {
             Formatting = Formatting.Indented
         };
         writer.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
         writer.WriteStartElement("SPITools");
         writer.Close();
         document.Load(comment.FileName);
         XmlNode documentElement = document.DocumentElement;
         DoOnOpenSaveComment.setComment(documentElement, comment.Comment);
         this.StoreFifoRead(documentElement, innerRead, deviceName);
         MemoryStream outStream = new MemoryStream();
         document.Save(outStream);
         outStream.Seek(0L, SeekOrigin.Begin);
         TextReader reader = new StreamReader(outStream);
         FileStream stream = new FileStream(comment.FileName, FileMode.Create, FileAccess.Write);
         TextWriter writer2 = new StreamWriter(stream);
         writer2.Write(Code.EncryptDecrypt(reader.ReadToEnd()));
         writer2.Flush();
         stream.Close();
     }
 }