Hi,

Two different routines below doing two similar operations, I'm sure you get the 'jist'. I prefer using 'METHOD 1' as I'm going through my code trying to get away from anything that uses the visualbasic namespace.

The file 'myfile.dat' is getting accessed by another program which is constantly being updated. If I try to use method 1 I get an error as another application is using it, which is true, Method 2 works fine because of the 'OpenShare.Shared', is there an equivalent for the streamreader.

I just want to open using streamreader method a file that is being used.

Anyone?

Thanks
Wayne


Code:
'METHOD 1
Dim strBuffer As String
Dim srFile As StreamReader = File.OpenText(Application.StartupPath & "\myfile.dat")
strBuffer = srFile.ReadToEnd
Dim InfoList() As String = strBuffer.Split(Environment.NewLine)
srFile.Close()

'METHOD 2
Dim FileNum As Integer = FreeFile()
FileOpen(FileNum, Application.StartupPath & "\myfile.dat", OpenMode.Input, OpenAccess.Read, OpenShare.Shared)
ProgValue = LineInput(FileNum)
FileClose(FileNum)