.Net instances of multiple applications but one document

My WPF application can open and edit individual documents. I'm looking for a neat approach that allows me to run multiple instances of my WPF application, but allow only one document to open in a single application instance. If a user tries to open a document that is already open in another instance, I need to open a dialog box to tell them and allow them to switch to another application instance if necessary.

Thanks Dan

+4
source share
1 answer

One approach is to try to make an exclusive file lock when it is opened. When your other application instance tries to open the file, an IOException will be thrown. You can catch this exception and show your user a message that the file is already open in another application. This scenario should be considered in any case, since the file may be opened in another application that does not belong to you.

+3
source

Source: https://habr.com/ru/post/1334245/


All Articles