On 15 May, 09:09, RichS <R...@discussions.microsoft.com> wrote:
> Is this for reading, writing or both
> --
> Richard Siddaway
> Please note that all scripts are supplied "as is" and with no warranty
> Blog:http://richardsiddaway.spaces.live.com/
> PowerShell User Group:http://www.get-psuguk.org.uk
>
> "char1iecha1k" wrote:
> > 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
I want to open file for reading, and when open disallow any other
process from opening that file. So far I have this
$test1=new-object System.IO.FileStream("test1.txt",
[System.IO.FileMode]::Open)
Now I need to know how to return the state of the file into a variable
so that my script can move on to the next unopen file ie
for each file in folder open file (if $file already open then return,
else process job)
hope that makes sense