private void newPackButton_Click(object sender, EventArgs e) { if (saveFileDialog.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { try { Package newpack = new Package(File.Create(saveFileDialog.FileName)); writeManifest(new PackageManifest { Version = 1 }); newpack.CreateEntry(Path.Combine(Path.GetTempPath(), "info.xml")); newpack.Save(saveFileDialog.FileName); newpack.Close(); openFileDialog.FileName = saveFileDialog.FileName; openFile(); MessageBox.Show(this, "New package created.", Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(this, "Couldn't create new package: " + ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (File.Exists(Path.Combine(Path.GetTempPath(), "info.xml"))) File.Delete(Path.Combine(Path.GetTempPath(), "info.xml")); } } }
void openFile() { if (pack != null) pack.Close(); samplesListView.Items.Clear(); ClearDetails(); packAuthorTextBox.Text = packDescriptionTextBox.Text = packWebTextBox.Text = string.Empty; fileNameLabel.Text = string.Empty; pack = null; manifest = null; curEntry = null; pack = new Package(File.OpenRead(openFileDialog.FileName)); pack.Load(); fileNameLabel.Text = Path.GetFileName(openFileDialog.FileName); refreshSamples(); }
private void packPackButton_Click(object sender, EventArgs e) { folderBrowserDialog1.Description = "Select folder to package"; if (folderBrowserDialog1.ShowDialog(this) == System.Windows.Forms.DialogResult.OK && saveFileDialog.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { Package newpack = null; try { newpack = new Package(File.Create(saveFileDialog.FileName)); foreach (string path in Directory.GetFiles(folderBrowserDialog1.SelectedPath)) { newpack.CreateEntry(path); } ProgressForm prog = new ProgressForm(callback => newpack.Save(saveFileDialog.FileName, callback)); prog.ShowDialog(this); if (prog.Error == null) { MessageBox.Show(this, "Packing successful.", Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(this, "Error while packing: " + prog.Error, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(this, "Error while packing: " + ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (newpack != null) newpack.Close(); } } }