>>Unexpectedly I realized that plain
>>
>>
>>Dim lcDataText As New System.IO.StreamReader(“path\text_file.txt”)
>>
>>
>>opens file exclusively preventing access to this file from another independent application.
>>
>>Another independent application (VFP9) uses code like:
>>
>>rst_DTW = CreateObject("ADODB.Recordset")
>>rst_DTW.Open("select * from " + lcfile , cnnText, adOpenStatic, adLockReadOnly)
>>
>>
>>And if this (another) process opens the file first then the first process can also work with the file.
>>
>>
>>So far I tried to follow several examples, but with no luck.
>>
>>1. Setting file attributes to READONLY.
>>
>>2.
>>Dim lcDataText As System.IO.StreamReader = System.IO.File.OpenText(lcfilename)
>>
>>
>
>This works for me (I can read from bigfile.txt with a text editor while the sub is also reading form the file).
>
> Private Sub TestStreamReader()
>
> Dim fs As New FileStream("c:\temp\bigfile.txt", _
> FileMode.Open, _
> FileAccess.Read, _
> FileShare.ReadWrite)
>
> Dim sr As New StreamReader(fs)
> Dim text As String
>
> Do While Not sr.EndOfStream
> text = sr.ReadLine()
>
>
> Loop
>
> sr.Close()
> fs.Close()
>
> End Sub
>
>>
>>3. Dim fs1 As System.IO.FileStream = New System.IO.FileStream(lcfilename, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)
>>Dim lcDataText As New System.IO.StreamReader(fs1)
>>
>>Here in #3 when adding System.IO.FileShare.Read a note message pops up saying
>>“… However, even if this flag is specified, additional permissions might still be needed to access the file.” Probably I am falling under this “additional permissions” category, but what are they, and how to set them properly?
>>
>>In addition, in another separate application I can use the following with no problem:
>>CREATE CURSOR yy (lcrec c(200))
>>Append from (lcfile) sdf
>>
>>Looks like it is an evidence that something should be set for ADO recordset or connection.
>>
>>Any recommendations are welcome.
>>
>>
>>Thanks
Bruce,
It is not the case; see my original notes about "something should be set for ADO recordset or connection". I wonder whether you can work with ADO recordset in this scenario.