This is how I open the file
srBCAS = New StreamReader(m_sServer & "\log.txt",
System.Text.Encoding.Default)
Thank you
You have to allow shared access explicitly:
\\\
Dim Stream As New FileStream( _
"C:\foo.txt", _
FileMode.Open, _
FileAccess.Read, _
FileShare.ReadWrite _
)
Using Reader As New StreamReader(Stream)
...
End Using
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
I beleive you'd better use "Using" statement to do all the disposal
operation automatically, thus the underlying and all resources will be
freed.
Using srBCAS As New StreamReader(m_sServer & "\log.txt",
System.Text.Encoding.Default)
' Code...Typically srBACS.ReadToEnd()
End Using
Hope this helps,
Onur Güzel
That is helpful for making sure that the file is properly closed when
you are done with it.
However, that is not the main problem here. The OP want's one process to
be able to write to the file while another process is still reading it.
As already mentioned, the solution is to specify the sharing mode when
opening the stream.
--
Göran Andersson
_____
http://www.guffa.com
"Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at> wrote in message
news:Oe7NKY$zIHA...@TK2MSFTNGP02.phx.gbl...