Пример #1
0
        // Open a file list.
        private void OpenFileList(string filename)
        {
            try {
                FileList = new FileList(filename);
            } catch (FileTypeException) {
                // Couldn't figure it out, ask the user what they want to do.
                FrmChooseType fct = new FrmChooseType();
                if (fct.ShowDialog(this) == DialogResult.Cancel)
                {
                    return;
                }

                try {
                    FileList = new FileList(filename, fct.FileListType);
                } catch (FileTypeException) {
                    // Unknown format.
                    MessageBox.Show(filename + " is not a supported file verification list format.",
                                    "Verifier", MessageBoxButtons.OK, MessageBoxIcon.Error);
                } catch (Exception ex) {
                    throw ex;
                }
            } catch (Exception ex) {
                // Bad error.
                MessageBox.Show("Could not open file verification list:" +
                                Environment.NewLine + Environment.NewLine +
                                filename +
                                Environment.NewLine + Environment.NewLine +
                                ex.Message,
                                "Verifier", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // In case nothing shows up, let the user know that we tried, but didn't find anything.
            if (FileList.filelist.Count == 0)
            {
                MessageBox.Show("Could not find any entries in " +
                                filename,
                                "Verifier", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            FrmMain  fm       = new FrmMain();
            FileList fileList = null;

            if (args.Length > 0)
            {
                try {
                    fileList = new FileList(args[0]);
                } catch (FileTypeException) {
                    // Couldn't figure it out, ask the user what they want to do.
                    FrmChooseType fct = new FrmChooseType();
                    if (fct.ShowDialog(fm) == DialogResult.OK)
                    {
                        try {
                            fileList = new FileList(args[0], fct.FileListType);
                        } catch (FileTypeException) {
                            // Unknown format.
                            MessageBox.Show(args[0] + " is not a supported file verification list format.",
                                            "Verifier", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        } catch (Exception ex) {
                            throw ex;
                        }
                    }
                } catch (Exception ex) {
                    // Bad error.
                    MessageBox.Show("Could not open file verification list:" +
                                    Environment.NewLine + Environment.NewLine +
                                    args[0] +
                                    Environment.NewLine + Environment.NewLine +
                                    ex.Message,
                                    "Verifier", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            // Start the application.
            fm.FileList = fileList;
            Application.Run(fm);
        }