Exemplo n.º 1
0
        private bool ExportToFile(
            RegistryExplorer.Registry.RegKey key,
            RegistryExplorer.Export.RegExportFormat format,
            System.IO.Stream output
            )
        {
            bool success = true;

            using (output)
            {
                DisableControls();
                try
                {
                    using (new BusyCursor(this))
                    {
                        using (System.IO.StreamWriter writer = new System.IO.StreamWriter(output))
                        {
                            RegistryExplorer.Export.RegExporter.Export(
                                key
                                , RegistryExplorer.Export.ExportProvider.Create(format, writer)
                                );
                        }
                    }
                }
                catch
                {
                    success = false;
                }
                EnableControls();
            }

            return(success);
        }
Exemplo n.º 2
0
        private void btnExport_Click(object sender, System.EventArgs e)
        {
            RegistryExplorer.Registry.RegKey key;
            if ((key = RegistryExplorer.Registry.RegKey.Parse(cmbBranch.Text)) == null)
            {
                UIUtility.DisplayError(this, RegistryExplorer.Properties.Resources.Error_InvalidKey, cmbBranch);
                return;
            }

            RegistryExplorer.Export.RegExportFormat format = GetExportFormat();


            System.IO.Stream output;
            try
            {
                output = System.IO.File.OpenWrite(txtFile.Text);
            }
            catch
            {
                UIUtility.DisplayError(this, RegistryExplorer.Properties.Resources.Error_FileOpenFail, txtFile);
                return;
            }

            bool success = ExportToFile(key, format, output);

            if (!success)
            {
                UIUtility.DisplayError(this, RegistryExplorer.Properties.Resources.Error_ExportFail);
            }
            else
            {
                UIUtility.InformUser(this, RegistryExplorer.Properties.Resources.Info_ExportSuccess);
                this.Close();
            }
        }