private void saveToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog saveXSCFileDialog = new SaveFileDialog(); saveXSCFileDialog.Title = "Save"; saveXSCFileDialog.InitialDirectory = XSCLocation; saveXSCFileDialog.Filter = "Xenon Script Container|*.xsc"; saveXSCFileDialog.FilterIndex = 1; saveXSCFileDialog.RestoreDirectory = true; if (saveXSCFileDialog.ShowDialog() == DialogResult.OK) { string newXSCFileLocation = saveXSCFileDialog.FileName; xscToSave = new XSC(); List <byte> newXSCFileBytes = new List <byte>(); //XSC Name try { xscToSave.SetNewXSCName(XSCNameTextBox.Text); } catch (InvalidDataException) { MessageBox.Show("XSC name can only contain letters, numbers and underscores, and cannot end in an underscore"); return; } xscToSave.SetNewParamCount(paramCountTextBox.Text); //XSC ASM string convertStatus = xscToSave.ConvertASMtoBytes(assemblyTextEditor.Text); if (convertStatus != "ASM converted successfully") { MessageBox.Show(convertStatus); return; } //Static Variables xscToSave.ConvertNewStaticVariablesTable(staticVariables.Items.Cast <int>().ToList()); //Natives convertStatus = xscToSave.ConvertNewNativeTableBytes(); if (convertStatus != "Natives Table converted successfully") { MessageBox.Show(convertStatus); return; } //String xscToSave.ConvertNewStringTable(); //Combine all the tables xscToSave.MergeXSCTables(); //outputTextBox.Text = BitConverter.ToString(xscToSave.GetNewXSCBytes()).Replace("-", " "); try { File.WriteAllBytes(newXSCFileLocation, xscToSave.GetNewXSCBytes()); XSCLocation = newXSCFileLocation; } catch (IOException) { MessageBox.Show("I/O Exception while saving XSC to specified location"); return; } catch (UnauthorizedAccessException) { MessageBox.Show("Error saving XSC to specified location"); return; } //re-open certain parts xscToOpen = new XSC(newXSCFileLocation); //string table stringTable.Enabled = true; stringTable.DataSource = xscToOpen.GetStringTable(); //natives table nativesTable.Enabled = true; nativesTable.DataSource = xscToOpen.GetNativesTable(); } }