private void QuickSave(string filePath)
{
if (filePath != null)
{
if (File.Exists(filePath))
{
try
{
File.WriteAllLines(filePath, scripts[tabControl1.SelectedIndex].Lines.ToArray());
tabControl1.TabPages[tabControl1.SelectedIndex].Text = Path.GetFileNameWithoutExtension(filePath);
}
catch
{
MessageBox.Show("File could not be written. Saving cancelled.");
}
}
else
{
DialogResult result = saveFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
File.WriteAllLines(saveFileDialog1.FileName, scripts[tabControl1.SelectedIndex].Lines.ToArray());
newScriptNames.Remove(Int32.Parse(tabControl1.TabPages[tabControl1.SelectedIndex].Text.Split(' ')[1]));
tabControl1.TabPages[tabControl1.SelectedIndex].Text = Path.GetFileNameWithoutExtension(saveFileDialog1.FileName);
currentlyOpenBS[tabControl1.SelectedIndex] = saveFileDialog1.FileName;
}
}
}
else
{
DialogResult result = saveFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
File.WriteAllLines(saveFileDialog1.FileName, scripts[tabControl1.SelectedIndex].Lines.ToArray());
newScriptNames.Remove(Int32.Parse(tabControl1.TabPages[tabControl1.SelectedIndex].Text.Split(' ')[1]));
tabControl1.TabPages[tabControl1.SelectedIndex].Text = Path.GetFileNameWithoutExtension(saveFileDialog1.FileName);
currentlyOpenBS[tabControl1.SelectedIndex] = saveFileDialog1.FileName;
}
}
}