Open File with Process - CSharp Operating System

CSharp examples for Operating System:Process

Description

Open File with Process

Demo Code


using System.Threading.Tasks;
using System.Threading;
using System.Text;
using System.Linq;
using System.IO;/*from   w w w. ja va2  s .com*/
using System.Diagnostics;
using System.Collections.Generic;
using System;

public class Main{
        public static bool OpenFile(string fileName, ref int exitCode)
        {
            try
            {
                System.Diagnostics.Process proc;
                proc = new System.Diagnostics.Process();
                proc.EnableRaisingEvents = false;
                proc.StartInfo.FileName = fileName;
                proc.Start();
                proc.WaitForExit();
                exitCode = proc.ExitCode;
                return true;
            }
            catch (System.Exception ex)
            {
                return false;
            }
        }
}

Related Tutorials