Created
August 15, 2015 18:05
-
-
Save IISResetMe/99af1a350440ee538c94 to your computer and use it in GitHub Desktop.
Count lines in file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Measure-Lines { | |
param($Path = 'C:\log.txt') | |
$FileStream = New-Object IO.FileStream ($Path,[System.IO.FileMode]::Open,[System.IO.FileAccess]::Read,[System.IO.FileShare]::ReadWrite) | |
$StreamReader = New-Object System.IO.StreamReader $FileStream | |
$TotalLines = 0 | |
while($StreamReader.ReadLine() -ne $null){ | |
$TotalLines++ | |
} | |
$TotalLines | |
$StreamReader.Close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment