Can I overwrite a file that is currently open by another user

I have several files that I should update periodically in a process written in VB.net. These files are located on the server and in the part of the domain that many users can access. These files should never be recorded as they are for reference only. I need to overwrite some of them, even if the user has opened them. Is it possible to do this? Currently, file permissions are not set as read-only, but I can do this while the user under the process is still allowed to overwrite them.

UPDATE: thanks for your answers. The pdf files also open by clicking on them from the Windows File Explorer. This also happens when the user simply has the file selected in Windows Explorer.

+3
source share
3 answers

It depends on the sharing mode that was used when users opened files. See the FileShareenum Section (which is accepted by some file overloads) for more information .

+2
source

, , , . , , - , . .

0

, , .

catch try catch, " ....". .

:

try
{
    .
    .
    .
    your update statement here
    .
    .
}
catch (Exception ex)
{
    if (ex.Message.IndexOf("Access to path") < 0)
        throw ex;
}
0

All Articles