|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
read file without locking it.Hi, 2 questions: 1. I want to read a file in without locking it, as it is Log file. 2. I want to be able to read from the last point it wa read upto. The project is: Search through ftp log files for certain files download to our ftp site. This will be on a schedule so I would like to pass to my database the point (in bytes) where I have read upto. Then next time I check it I want to only ready from the amount of bytes recalled from the database. Writing the filedetails and retrieving the file details to the Db are not a problem, just how to go about reading the file in the manor described above. regards John. -- Kind Regards John. John please don't spam me! wrote:
> VB.Net 2003 What have you tried and what problems are you having? The StreamReader> Hi, > 2 questions: > 1. I want to read a file in without locking it, as it is Log file. > 2. I want to be able to read from the last point it wa read upto. > > The project is: > Search through ftp log files for certain files download to our ftp site. > This will be on a schedule so I would like to pass to my database the point > (in bytes) where I have read upto. Then next time I check it I want to only > ready from the amount of bytes recalled from the database. can be used to read the file as well as opening it for read access only without locking it. Also, it allows for seeking into the file to a certain point. What problem are you experiencing? Thanks Chris,
The problem I am experiencing was basically which way to go. I had not coded anything as yet to read the file, but now you have said StreamRead will suit my needs I will delve into this an try to put some code together. For the few projects I have done I have used myfileobject.opentextfile(c:\.......) I see in help there is an example of StreamRead: ' Open the stream and read it back. fs = File.Open(path, FileMode.Open, FileAccess.Read) Dim b(1024) As Byte Dim temp As UTF8Encoding = New UTF8Encoding(True) Do While fs.Read(b, 0, b.Length) > 0 Console.WriteLine(temp.GetString(b)) If I run into problems with it then you will no doubt hear from me. Thanks for the prompt response, I will start tomorrow with fresh eyes. -- Show quoteHide quoteKind Regards John. "Chris Dunaway" wrote: > John please don't spam me! wrote: > > VB.Net 2003 > > Hi, > > 2 questions: > > 1. I want to read a file in without locking it, as it is Log file. > > 2. I want to be able to read from the last point it wa read upto. > > > > The project is: > > Search through ftp log files for certain files download to our ftp site. > > This will be on a schedule so I would like to pass to my database the point > > (in bytes) where I have read upto. Then next time I check it I want to only > > ready from the amount of bytes recalled from the database. > > What have you tried and what problems are you having? The StreamReader > can be used to read the file as well as opening it for read access only > without locking it. Also, it allows for seeking into the file to a > certain point. > > What problem are you experiencing? > > "John please don't spam me!"
<Johnpleasedontspamme@discussions.microsoft.com> schrieb: > 1. I want to read a file in without locking it, as it is Log file. Open the 'FileStream' with 'FileShare.ReadWrite' specified, which will allow other applications to read and write to the file while your application is keeping it opened. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> Thanks Herfield, I saw this in help and was thinking of trying it. I am
thinking no longer after your response - I will us it, thanks. -- Show quoteHide quoteKind Regards John. "Herfried K. Wagner [MVP]" wrote: > "John please don't spam me!" > <Johnpleasedontspamme@discussions.microsoft.com> schrieb: > > 1. I want to read a file in without locking it, as it is Log file. > > Open the 'FileStream' with 'FileShare.ReadWrite' specified, which will allow > other applications to read and write to the file while your application is > keeping it opened. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://dotnet.mvps.org/dotnet/faqs/> > >
2005 too smart for it's own good?
A Question on VB Classes Controls of a form convert html string into a html document Reading text files How to convert an Image file to PDF file Doubling up of data in DataView-bound DataGrid?? buttons stopped working Reading logon/logoff datetime Position to a Brazilian software developer ? |
|||||||||||||||||||||||