I have a file called C:\FindPos.txt
with this content:
Lorem ipsum dolor sit amet,
consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut.
I have an Offset and want to find the Line and Column
Current experiments:
$path = 'C:\FindPos.txt'
$oneStringcontent = [System.IO.File]::ReadAllText($path)
$fileContent = get-content -Path $path
$StartLine = 3
$StartColumn = 26
$StartOffset = 98
write-host "$($oneStringcontent[$StartOffset+1])"
$fileContent | ForEach-Object {
$currentLine = $_.ReadCount
if ($currentLine -eq $StartLine) {
write-host "Line $StartLine | Column = $StartColumn | Line = $($_) | Char = $($_[$StartColumn +1])"
}
}
If I read the file as one string, I can grab the correct character from the array, but no idea how to turn that into Ln/Col.
If I read it line by line, I have the opposite problem (also, the character column position doesn't match)