Process.Start Catch all FileName/Arguments code
<p>I have some code that I wanted to improve. It uses Process.Start and should be able to handle any input any argument, and still work. 
I don't think I have covered all the bases. Can anyone suggest a better/more thorough approach?</p>

<p>ToMaybeUri is an extension method that tries to create a Uri.</p>

<p>ToValidMailToArgument is an extension method that adds "attachments="</p>

<p>IsValidEmail is an extension method that does a RegEx on the email address.</p>

<pre><code> public static void RunProcess(string fileName, string Params)
    {
        var useProcessStart = true;

        var validFile = false;
        var validDir = false;
        var validEmail = false;
        var validURL = false;

        var proc = new Process();
        var info = new ProcessStartInfo(fileName);
        info.UseShellExecute = true;
        info.Arguments = Params;

        //try catches here in case the syntax of the string has invalid characters for dir/file
        try
        {
            var di = new DirectoryInfo(fileName);
            validDir = di == null ? false : di.ExistsNow();
        }
        catch (Exception ex) { }

        try
        {
            var fi = new FileInfo(fileName);
            validFile = fi == null ? false : fi.Exists();
        }
        catch (Exception ex) { }

        if (Params == "")
        {

            if (validFile)
            {
                if (Path.GetExtension(fileName).ToUpper() == ".CHM")
                {

                    var helpProvider1 = new HelpProvider();
                    helpProvider1.HelpNamespace = fileName;

                    Help.ShowHelp(Application.OpenForms[0], helpProvider1.HelpNamespace);

                    MessageBox.Show(msg);

                    return;
                }
            }
            else if (validDir)
            {
                //skip
            }
            else if (fileName.IsValidEmail())
            {
                validEmail = true;                  
                info.FileName = "mailto:" + info.FileName;
                info.Arguments = "";

            }
            else if (fileName.IsValidUrl())
            {
                validURL = true;
                info.FileName = fileName.ToMaybeUri().Value.ToString();
                info.Arguments = "";
            }
            else
            {
                MessageBox.Show(fileName + " does not exist.");
            }
        }
        else
        {
            //and has params
            if (Path.GetExtension(fileName).ToUpper() == ".PDF" &amp;&amp; Params.ToLower().StartsWith("p"))
            {
                int pageNum = 0;
                string pageNumString = Grazer.Utilities.Strings.Right(Params, Params.Length - 1);
                int.TryParse(pageNumString, out pageNum);

                //PDFLocation = "/A \"page=" + pageNum + "=OpenActions\" \"" + ssGlobals.ssStartDir + "\\Example.pdf\""
                string app = GrRegistry.GetApplicationFromExtension(".PDF");

                if (Path.GetFileNameWithoutExtension(app).ToUpper() == "ACROBAT" || Path.GetFileNameWithoutExtension(app).ToUpper() == "ACRORD32")
                {
                    string PDFLocation = String.Format("/A \"page={0}=OpenActions\" \"{1}\"", pageNum, Path.GetFullPath(fileName));

                    info = new ProcessStartInfo(app);
                    info.Arguments = PDFLocation;
                }
            }
            else if (fileName.IsValidEmail())
            {
                validFile = false;

                try
                {
                    var fi = new FileInfo(info.Arguments);
                    validFile = fi == null ? false : fi.ExistsNow();
                }
                catch (Exception ex) { }

                info.FileName = String.Format("mailto:{0}{1}", fileName, new FileInfo(info.Arguments).ToValidMailToArgument());
                info.Arguments = "";                  
            }
        }

        if (useProcessStart)
        {
            proc.StartInfo = info;

            try
            {
                if (validURL || validFile || validDir || validEmail)
                    proc.Start();
            }
            catch (Exception ex)
            {
                switch (ex.Message)
                {
                    case "No process is associated with this object.":
                        break;
                    default:
                        MessageBox.Show(ex);
                        if (info.Arguments.ToEmptyIfNull().Length &gt; 0)
                            MessageBox.Show(String.Format("{0} could not be opened with parameters: {1}", info.FileName, info.Arguments));
                        else
                            MessageBox.Show(String.Format("{0} could not be opened", info.FileName));
                        break;
                }
            }
        }
    }
</code></pre>
