473,320 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

read file without locking it.

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.

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.
Sep 19 '06 #1
4 9496
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?

Sep 19 '06 #2
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.
--
Kind 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?

Sep 19 '06 #3
"John please don't spam me!"
<Jo******************@discussions.microsoft.comsch rieb:
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/>

Sep 19 '06 #4
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.
--
Kind Regards
John.
"Herfried K. Wagner [MVP]" wrote:
"John please don't spam me!"
<Jo******************@discussions.microsoft.comsch rieb:
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/>

Sep 20 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Dino | last post by:
dear all, i've created an application for a customer where the customer can upload ..csv-files into a specified ftp-directory. on the server, a php-script, triggered by a cronjob, reads all the...
4
by: francis70 | last post by:
Hi, I have these 2 problem? Is there a way in Oracle to read UNCOMMITED data. i.e. in Oracle the normal behaviour is that a user's updates to a table are visible to other users ONLY when the...
1
by: Zri Man | last post by:
I have found the DB2/UDB implentation of locks a little more hard to deal with than Oracle's locking. First I realize there is lock escalation. But it would help me if somebody loudly thought...
0
by: Andrew Dowding | last post by:
Hi Everybody, I have been looking at problems with my Windows Forms C# application and it's little Jet 4 (Access) database for the last few days. The Windows Forms app implements a facade and...
13
by: George | last post by:
Hi, I am re-writing part of my application using C#. This application starts another process which execute a "legacy" program. This legacy program writes to a log file and before it ends, it...
8
by: dosworldguy | last post by:
I have been having a very peculiar issue from a long time. I have an application where multiple clients read from a shared set of files. When a record is changed, sometimes the win9x clients...
2
by: DeanL | last post by:
Hi Guys, I've been trawling through this group for an answer to this but can't find one that works. I have an Access 97 db sitting on a Novell server that is accessed via a front end with...
5
by: troy | last post by:
Could someone please point me in the right direction on how to read in a large query with .net. I am trying to emulate a legacy database system so I don't know the upper bounds of the sql query....
26
by: Don Calloway | last post by:
I have created a <filename>.db1 (where <filenameis the name given to the database) Access database that is being used in multi-user mode. When the <filename>.db1 file is opened by a user, the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.