A program is running on multiple machines that share a network drive. It can use
... = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
to lock a file from writing. All the other instance then can only read it and display a warning, that the file is not writable.
How can I find out who (i.e. which machine) locked the file, to display that along the warning?
The only way I have ever seen this achieved is for the program that opens the file to leave behind a marker file, (.lock) or similar. This .lock file can then obviously contain whatever you want (username, machine etc) and can be read separately.
This assumes you have control over the software which is reading it on the other PC.