Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to lock a file on network (in Windows)?

I'm having a service (C# service) that runs on multiple computers and share the same file (on a network storage say NAS). I want to make sure that when performing a write operation, I should be able to acquire a lock on the file, write and then unlock it.

How can I lock a file on network, when writing to it ?

like image 349
atVelu Avatar asked Dec 05 '25 10:12

atVelu


1 Answers

Take a look at

FileStream.Lock Method and FileStream.Unlock Method

like image 136
Sorceri Avatar answered Dec 08 '25 00:12

Sorceri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!