In powershell, the command "Get-Content (filename)" doesn't have any problems reading a file locked for writing in read-only mode.
So Why can't I do the same using the .net function ReadAllLines from PowerShell? I don't understand why ReadAllLines() would be more intrusive than Get-Contents? All it does is reads the content of the file and then closes it.
Anyways, I prefer to use the .net functions over the native powershell functions because they are less messed up, with the exception of ReadAllLine not working correctly with respect to partially locked files... Is there a way to get ReadAllLines to .net to work the same as Get-Content when reading a partially locked file... one that's ok for reading but locked for writing?
[Collections.Generic.List[string]]$lines = [System.IO.File]::ReadAllLines($file)
verse:
$arr1 = Get-Content $file
$lines = [Collections.Generic.List[string]]$arr1