public override void Save() { using (var sfrm = new SaveFileDialog()) { sfrm.FileName = Path.GetFileName(streamfilename); if (sfrm.ShowDialog() == DialogResult.OK) { if (sfrm.FileName == streamfilename) { MessageBox.Show(RDR_Explorer.Properties.Resources.ResourceManager.GetString("fErrOpened"), RDR_Explorer.Properties.Resources.ResourceManager.GetString("err"), MessageBoxButtons.OK, MessageBoxIcon.Error); Save(); return; } try { if (System.IO.File.Exists(sfrm.FileName)) { System.IO.File.Delete(sfrm.FileName); } using (System.IO.File.Create(sfrm.FileName)); } catch { MessageBox.Show(RDR_Explorer.Properties.Resources.ResourceManager.GetString("fErrNoPerm"), RDR_Explorer.Properties.Resources.ResourceManager.GetString("err"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } /* * entryIndex = 0; * if (!ReIndex(RootDirectory)) * { * MessageBox.Show("Failed to re-index the archive.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); * return; * } * * if (entryIndex + 1 != (_rpfFile.TOC.count)) * { * if (MessageBox.Show("The number of entries is equal to the number of TOC entries, this may cause archive corruption.", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.Cancel) * return; * } */ FileStream newRPFStream = new FileStream(sfrm.FileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); RDR_Explorer.Saving saveDialog = new RDR_Explorer.Saving(newRPFStream, _rpfFile); saveDialog.ShowDialog(); newRPFStream.Close(); } } }
public override void Save() { using (var sfrm = new SaveFileDialog()) { sfrm.FileName = Path.GetFileName(streamfilename); if (sfrm.ShowDialog() == DialogResult.OK) { if (sfrm.FileName == streamfilename) { MessageBox.Show(RDR_Explorer.Properties.Resources.ResourceManager.GetString("fErrOpened"), RDR_Explorer.Properties.Resources.ResourceManager.GetString("err"), MessageBoxButtons.OK, MessageBoxIcon.Error); Save(); return; } try { if (System.IO.File.Exists(sfrm.FileName)) { System.IO.File.Delete(sfrm.FileName); } using (System.IO.File.Create(sfrm.FileName)); } catch { MessageBox.Show(RDR_Explorer.Properties.Resources.ResourceManager.GetString("fErrNoPerm"), RDR_Explorer.Properties.Resources.ResourceManager.GetString("err"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } /* entryIndex = 0; if (!ReIndex(RootDirectory)) { MessageBox.Show("Failed to re-index the archive.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (entryIndex + 1 != (_rpfFile.TOC.count)) { if (MessageBox.Show("The number of entries is equal to the number of TOC entries, this may cause archive corruption.", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.Cancel) return; } */ FileStream newRPFStream = new FileStream(sfrm.FileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); RDR_Explorer.Saving saveDialog = new RDR_Explorer.Saving(newRPFStream, _rpfFile); saveDialog.ShowDialog(); newRPFStream.Close(); } } }