Reputation: 3934
I've got a C# Winforms Application that processes queried data into Mail Merge documents. How can I check on application start-up to see if current user has a Microsoft Word Instance Open, and if so, alert them to close before proceeding?
Upvotes: 2
Views: 2893
Reputation: 6304
Use LINQ Any
:
var isRunning = Process.GetProcessesByName("winword").Any();
Upvotes: 3
Reputation: 994
Process[] processes = Process.GetProcessesByName("winword.exe");
if (processes.Length == 0)
//not running
else
//running
Upvotes: 2