Timeline for How to lock a file in Windows without changing it or using third party tools?
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 7, 2016 at 4:10 | comment | added | Simon Elms |
Note the $host.UI.RawUI.ReadKey(...) will fail in PowerShell ISE as ReadKey is not implemented for the ISE. The workaround is [void](Read-Host 'Press Enter to continue') . Not exactly the same as the user has to press Enter rather than any key. However, good enough for most purposes. The workaround came from this blog post: jeffwouters.nl/index.php/2016/06/…
|
|
Dec 29, 2014 at 11:55 | history | edited | Dan | CC BY-SA 3.0 |
added 56 characters in body
|
Dec 28, 2014 at 22:43 | comment | added | Dan | @moab The file is closed and the handle released at the end. | |
Dec 28, 2014 at 20:23 | comment | added | Breakthrough |
Nice answer. For the curious, here's the MSDN link to the File::Open method detailing the parameters of the call (specifically, the last argument, 'None' , declines sharing the file with any other threads/processes - and likewise, provisions exist to lock the file for read/write only, or a combination thereof).
|
|
Dec 28, 2014 at 14:49 | vote | accept | marsh-wiggle | ||
Dec 28, 2014 at 14:49 | comment | added | marsh-wiggle | Great! Thanks! To my shame, I must confess that I develop in powershell and did not think about using the .net classes for this. [I hope that will not go any further :-)] | |
Dec 28, 2014 at 13:50 | history | answered | Dan | CC BY-SA 3.0 |