Reputation: 497
My .NET app updates a certain .xls file located in a shared folder inside the domain. Using VB.NET, how can I check if that file is being used by another user and unshare/close it, so my code can update the file properly? NOTE:.Exe file(my app) will be executed in the server where shared folder is.
Upvotes: 0
Views: 890
Reputation: 4001
Windows and NTFS is designed to prevent this scenario. Unless you:
Taskkill
command-line command to kill all Excel.exe instances (since you won't necessarily know which one has it open) on the machine - another undesirable step to takeProcess.Start
them.you just can't get Windows/NTFS to release the file lock.
A possible alternative that I'm not sure will work with an xls (as opposed to an xls_) is to make the file shared, though this has some limitations.
Upvotes: 2