private void ProcessCommandLine(string[] args)
        {
            MSUtils util = new MSUtils();

            string invalidSwitchMessage = string.Concat("*** ERROR ***: Invalid switch {0}!", Environment.NewLine);

            switch (args.Length)
            {
                case 0:
                    Console.WriteLine(CopyrightsStr());
                    Console.WriteLine(UsageStr());
                    break;
                case 1:
                    if (args[0].ToUpper().Trim() != "-H")
                    {
                        Console.WriteLine(string.Format(invalidSwitchMessage, args[0]));
                    } 

                    Console.WriteLine(UsageStr());
                    break;
                default:
                    string option = args[0].ToUpper().Trim();

                    if (option == "-S")
                    {
                        string destFolder = Environment.CurrentDirectory;

                        if (args.Length > 2)
                        {
                            destFolder = args[2];
                        }

                        util.ConvertToSinglePageTiffs(args[1].Trim(), destFolder);
                    }
                    else if (option == "-O")
                    {
                        if (args.Length < 4 || args[2].ToUpper().Trim() != "-M")
                        {
                            Console.WriteLine(string.Format(invalidSwitchMessage, "options"));
                        }
                        else
                        {
                            string destFile = args[1].Trim();
                            List<string> fileList = new List<string>();

                            for (int i = 3; i < args.Length; i++)
                            {
                                fileList.Add(args[i]);
                            }

                            util.ConvertToMultiPageTiff(fileList, destFile);
                        }
                    }
                    else if (option == "-C")
                    {
                        if (args.Length != 2)
                        {
                            Console.WriteLine(string.Format(invalidSwitchMessage, "options"));
                        }
                        else
                        {
                            if (!File.Exists(args[1]))
                            {
                                Console.WriteLine(String.Format("*** ERROR ***: Configuration File {0} does not exist.", args[1]));
                            }
                            else
                            {
                                Config cfg = new Config();
                                string err = string.Empty;
                                ConfigurationValues values = cfg.GetConfigurations(args[1],ref err);

                                if (err != string.Empty) Console.WriteLine(err);

                                string[] fns = values.InputFiles.Split(';');
                                switch (values.Action)
                                {                                        
                                    case Config.ACTION_SPLIT:                                        
                                        foreach (string fn in fns)
                                        {
                                            util.ConvertToSinglePageTiffs(Path.Combine(values.SrcDir,fn), Path.Combine(values.DestDir,Path.GetFileNameWithoutExtension(fn)));
                                        }
                                        break;
                                    case Config.ACTION_MERGE:
                                        fns = values.InputFiles.Split(';');
                                        List<string> list = new List<string>();
                                        foreach (string fn in fns)
                                        {
                                            Console.WriteLine(values.SrcDir);
                                            list.Add(Path.Combine(values.SrcDir, fn));                                     
                                        }
                                        util.ConvertToMultiPageTiff(list, Path.Combine(values.DestDir,values.OutputFile));
                                        break;
                                    default:
                                        Console.WriteLine(String.Format("*** ERROR ***: Unrecognized configuration key {0}.", values.Action));
                                        break;
                                }
                            }
                        }
                    }
                    break;
            }
        }
        private void BtnConvert_Click(object sender, EventArgs e)
        {
            List<string> files = new List<string>();

            foreach (object o in FileList.Items)
            {
                files.Add(o as string);
            }

            if (files.Count == 0) return;

            Cursor = Cursors.WaitCursor;
            try
            {

                MSUtils util = new MSUtils();

                if (RdoMultiToSingle.Checked)
                {

                    foreach (string fn in files)
                    {
                        util.ConvertToSinglePageTiffs(fn, Path.GetFileNameWithoutExtension(fn));
                    }
                }
                else
                {
                    util.ConvertToMultiPageTiff(files, OutputFileNameTextBox.Text);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor = Cursors.Default;
                MessageBox.Show("The selected files has been successfully processed.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }