You need to specify correct sharing options and open mode when creating underlying FileStream
. Since there is no constructor of StreamReader
that passes all necessary arguments you need to construct FileStream
first using FileStream(String, FileMode, FileAccess, FileShare) and than create StreamReader
on it using SrteamReader(Stream).
I think following should open IIS log file while it is being written to by IIS (if not - try other combinations of flags)
Using stream As New New FileStream( _
"Test#@@#.dat", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
Using sr As New StreamReader(stream)