private void importPatchToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog.Title = "Please select a compressed patch file"; openFileDialog.CheckFileExists = false; openFileDialog.Filter = "Zip File (*.zip)|*.zip|Rar File (*.rar)|*.rar"; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { if (!File.Exists(openFileDialog.FileName)) { MessageBox.Show(this, "That file does not exist!"); return; } CRC32 crc32 = new CRC32(); crc32.PercentCompleteChange += new ProgressChangeHandler(OnPercentChange); FileStream stream = File.OpenRead(openFileDialog.FileName); uint crc = crc32.GetCrc32(stream); stream.Close(); string location = string.Empty; PathInputForm form = new PathInputForm(); form.PatchLocation = "http://"; if (form.ShowDialog(this) == DialogResult.Cancel) { return; } if (!form.PatchLocation.Contains(Path.GetFileName(openFileDialog.FileName))) { if (!form.PatchLocation.EndsWith("/")) { form.PatchLocation += "/"; } form.PatchLocation += Path.GetFileName(openFileDialog.FileName); } PatchlistFile file = new PatchlistFile(form.PatchLocation, crc, new FileInfo(openFileDialog.FileName).Length); if (!listBox.Items.Contains(file) && !DuplicateFileNames(file)) { _needsSaving = true; listBox.Items.Add(file); } } }
private void importPatchToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog.Title = "Please select a compressed patch file"; openFileDialog.CheckFileExists = false; openFileDialog.Filter = "Zip File (*.zip)|*.zip|Rar File (*.rar)|*.rar"; if( openFileDialog.ShowDialog(this) == DialogResult.OK ) { if( !File.Exists(openFileDialog.FileName) ) { MessageBox.Show(this, "That file does not exist!"); return; } CRC32 crc32 = new CRC32(); crc32.PercentCompleteChange += new ProgressChangeHandler(OnPercentChange); FileStream stream = File.OpenRead(openFileDialog.FileName); uint crc = crc32.GetCrc32(stream); stream.Close(); string location = string.Empty; PathInputForm form = new PathInputForm(); form.PatchLocation = "http://"; if( form.ShowDialog(this) == DialogResult.Cancel ) return; if (!form.PatchLocation.Contains(Path.GetFileName(openFileDialog.FileName))) { if (!form.PatchLocation.EndsWith("/")) form.PatchLocation += "/"; form.PatchLocation += Path.GetFileName(openFileDialog.FileName); } PatchlistFile file = new PatchlistFile(form.PatchLocation, crc, new FileInfo(openFileDialog.FileName).Length); if (!listBox.Items.Contains(file) && !DuplicateFileNames(file)) { _needsSaving = true; listBox.Items.Add(file); } } }