Month: July 2017
Windows: open file for writing (lock file)
Sometimes you need to lock file and investigate how an application under the test will be working.
There are few steps to implement it:
- Open PowerShell console
- Write the following code:
$file=[System.io.File]::Open('full/path/to/your/file', 'append', 'Write', 'None')
- Your test steps…
- Don’t forget to close the file after testing by
$file.Close()
P.S.: It’s possible that it’ll be the error in your application log:
Exception calling "Open" with "4" argument(s): "The process cannot access the file 'full/path/to/your/file'' because it is being used by another process."