Search Chirayu Software Solutions Blog

Thursday, September 26, 2013

check if a program is already running in c#

 if (System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Count() > 1)
            { 
                //application is already running
                MessageBox.Show("Cannot start,  please close it before starting again");
                System.Diagnostics.Process.GetCurrentProcess().Kill();

            }

Post a Comment