private void buttonImport_Click(object sender, EventArgs e) { if (!FileOpen) { return; } OpenFileDialog FileDialog = new OpenFileDialog(); FileDialog.DefaultExt = ".txt"; FileDialog.Filter = "Text file|*.txt|Any file|*.*"; FileDialog.FileName = CurrentFilename + "_export.txt"; if (FileDialog.ShowDialog() != DialogResult.OK) { return; } byte[] ImportFile; try { ImportFile = System.IO.File.ReadAllBytes(FileDialog.FileName); TSS.ImportText(ImportFile); } catch (Exception ex) { Util.DisplayException(ex); } if (checkBoxAutosave.Checked) { checkBoxAutosave.Checked = false; numericUpDown1_ValueChanged(sender, null); checkBoxAutosave.Checked = true; } else { numericUpDown1_ValueChanged(sender, null); } }
static void Main(string[] args) { int argc = args.Length; TSSFile TSS; switch (argc) { case 4: TSS = new TSSFile(System.IO.File.ReadAllBytes(args[0])); TSS.ImportText(System.IO.File.ReadAllBytes(args[1])); if (args[3] == "-erase") { foreach (TSSEntry e in TSS.Entries) { if (e.StringENG != null) { e.StringENG = ""; } } } System.IO.File.WriteAllBytes(args[2], TSS.Serialize()); break; case 3: TSS = new TSSFile(System.IO.File.ReadAllBytes(args[0])); TSS.ImportText(System.IO.File.ReadAllBytes(args[1])); System.IO.File.WriteAllBytes(args[2], TSS.Serialize()); break; default: Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); break; } }