Ejemplo n.º 1
0
        private void replaceFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FileNode Node = (FileNode)treeView1.SelectedNode;

            OpenFileDialog o = new OpenFileDialog()
            {
                Filter   = Node.GetFileFilter(),
                FileName = Node.Entry.Name
            };

            if (o.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            byte[] Data = File.ReadAllBytes(o.FileName);

            using (FileStream GCMStream = OpenGCMStream())
            {
                if (GCM.ReplaceFile(Node.Entry, GCMStream, Data))
                {
                    MessageBox.Show("File was successfully replaced.", "GCM", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("No space was found for the file. This shouldn't really happen unless a very large file was selected.", "GCM", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            RefreshPropertyGrid();
        }
Ejemplo n.º 2
0
        private void exportFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FileNode Node = (FileNode)treeView1.SelectedNode;

            SaveFileDialog s = new SaveFileDialog()
            {
                Filter   = Node.GetFileFilter(),
                FileName = Node.Entry.Name
            };

            if (s.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            using (FileStream Output = File.Open(s.FileName, FileMode.Create, FileAccess.Write),
                   GCMStream = OpenGCMStream())
            {
                GCM.ExportFile(Node.Entry, GCMStream, Output);
            }
        }