I need to ban an application if it starts from the same folder, but allow it if the same application runs from other folders.
The problem is when application closes it's becomes invisible but still is in the memory because it terminates some internal job.
It's very possible that user will start this application again from the same folder quickly when the old instance still terminates in the memory.
But from the other side it should be possible if this application runs from other folders.
Any clue how to do it in C#?
UPDATES:
1
In fact application writes some logs into the local files in subdirectory and into the local database file as well. So it's very possible that it could be some conflict between 2 instances.
2
Guid appGuid = Guid.Parse("305BACEA-4074-11E1-85E1-066E4854019B");
public MainWindow()
{
InitializeComponent();
using (Mutex mutex = new Mutex(false, @"Global\" + appGuid) )
{
if (!mutex.WaitOne(0, false))
{
// MessageBox.Show("Instance already running");
// Somehow here I have to get the path of the running instance.
// If the path the same as the current instance has I have do ban starting instance.
return;
}
GC.Collect();
}