Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Does StreamReader open file readonly?
Message
 
À
16/11/2009 17:24:02
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 8.0
Divers
Thread ID:
01434675
Message ID:
01435385
Vues:
28
>>>Yuri,
>>>Did you read my reply on Foxite? The culprit is using ADO on a text file. No matter what the mode is, it is ADO who is opening the file exclusively. StreamReader is innocent and really opens as readonly.
>>>
>>>PS: Schema.ini has no role. With or w/o it ADO would lock the file.
>>>Cetin
>>
>>Cetin,
>>
>>Please, review my reply there. A puzzle is that ADO does not open file exclusively. If I open it via ADO first, then I can open it with StreamReader, but not not vise versa. There I attached a package (code&file) to reproduce the behavior.
>>
>>Thanks
>
>Yuri,
>Checked (strangely I didn't see your reply before and the only way I could get there was to use the link that I gave to Naomi). My reply doesn't show up either so I post here as is:
>
>I tested your code + many variations. As I could see the culprit is ADO.
>If you have a chance to touch VFP side then as I said before, you could get a copy the file and use ADO on that individual copy.
>If you don't have a chance to touch to VFP side, then the only solution I could find is to use ADO on .Net side:
>
>
>Module Module1
>
>    Sub Main()
>
>        Dim curDir As String
>        curDir = System.IO.Path.GetDirectoryName(System.IO.Path.GetFullPath("BPDTW.TXT"))
>        Dim cnStream As ADODB.Stream
>        cnStream = CreateObject("ADODB.Stream")
>        cnStream.Open()
>        cnStream.Type = ADODB.StreamTypeEnum.adTypeText
>        cnStream.Charset = "ascii"
>        cnStream.LoadFromFile("BPDTW.TXT")
>        Dim content As String
>        content = cnStream.ReadText
>        Console.WriteLine(content)
>        Console.WriteLine(cnStream.State = ADODB.ObjectStateEnum.adStateOpen)
>        Console.WriteLine("Any key to close ADO STREAM")
>        Console.ReadLine()
>        cnStream.Close()
>    End Sub
>
>End Module
>
>
>Cetin

Cetin,

Thank you for your time, efforts, and ideas.

All the best,

Yuri Rubinov
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform