Example #1
0
        public static bool launchProgram(int iProgIndex)
        {
            //isLaunched=false;

            lastErrorString = null;
            if (extinfoNow != null)
            {
                if (extinfoNow.isSlotUsed(iProgIndex))
                {
                    try {
                        ProgChooser.IsAnswered = true;
                        //string sCommand=proginfoarrNow[iProgIndex].FullName+" \""+programArgs[iParam0]+"\"";
                        //ProcessStartInfo psiNow=new ProcessStartInfo(proginfoarrNow[iProgIndex].FullName,programArgs[iParam0]);
                        //Process ps=Process.Start(psiNow);
                        Process ps = new Process();
                        ps.StartInfo.FileName = extinfoNow.proginfoarr[iProgIndex].FullName;
                        if (openedFileFullName.Contains(" ") &&
                            openedFileFullName.Length > 2 &&
                            (openedFileFullName[0] != '"' || openedFileFullName[openedFileFullName.Length - 1] != '"'))
                        {
                            ps.StartInfo.Arguments = "\"" + openedFileFullName + "\"";
                        }
                        else
                        {
                            ps.StartInfo.Arguments = openedFileFullName;
                        }
                        ps.Start();
                        isLaunched = true;
                    }
                    catch (Exception exn) {
                        ProgChooser.Error_WriteLine("launchProgram could not finish for the following reason: " + exn.ToString());
                    }
                }
                else
                {
                    ProgChooser.Error_WriteLine("launchProgram could not find anything in slot " + iProgIndex.ToString());
                }
            }
            else
            {
                ProgChooser.Error_WriteLine("Sorry, ProgChooser has no info for that file extension");
            }
            return(ProgChooser.isLaunched);
        }        //end launchProgram