|
Re: Open file for exclusive access "char1iecha1k" <charlesgargent@gmail.com> wrote in message
news:1179176871.496647.42740@l77g2000hsb.googlegroups.com...
> Hi,
>
> I would like to open a file for exclusive access for the duration of a
> script. If the script fails or finishes the lock must be released.
> This is to prevent another user or process from accessing the same
> data file. I have googled to no avail.
>
> Thanks in advance
>
Perhaps you should try this FileStream constructor:
public FileStream (
string path,
FileMode mode,
FileAccess access,
FileShare share
)
And set the share parameter to FileShare.None.
--
Keith |