Reputation: 71
I have a requirement where one process continuously writes to the files in a particular folder. At the same time an another script moves the files from that folder to another folder. But files must not be moved while the first process is in the middle of writing to them. Is there any process/function in PowerShell which can fulfill this requirement?
Upvotes: 7
Views: 17363
Reputation: 9601
In Powershell the syntax is like this:
$path = "C:\file.txt"
$mode = "Open"
$access = "Read"
$share = "None"
$file = [System.IO.File]::Open($path, $mode, $access, $share)
$file.close()
There is more information available on this Class at the following URL:
http://msdn.microsoft.com/en-us/library/y973b725(v=vs.110).aspx
Upvotes: 17