473,545 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9537
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.op entextfile(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(Tr ue)

Do While fs.Read(b, 0, b.Length) 0
Console.WriteLi ne(temp.GetStri ng(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************ ******@discussi ons.microsoft.c omschrieb:
1. I want to read a file in without locking it, as it is Log file.
Open the 'FileStream' with 'FileShare.Read Write' 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************ ******@discussi ons.microsoft.c omschrieb:
1. I want to read a file in without locking it, as it is Log file.

Open the 'FileStream' with 'FileShare.Read Write' 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
9078
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 data, imports it into a mySQL database and deletes the .csv-file after the import. so far, so good. but in some cases the cronjobs starts...
4
40227
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 user commits. But in Informix there is this thing called ISOLATION LEVELS. For example by setting the ISOLATION LEVEL to DIRTY READ, a user will...
1
5007
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 out their answers to these following questions 1) The Default locking behaviour is ROW Level (Page I used to think) and the default lock is...
0
3159
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 implementation, data abstraction layer. But because each data adapter in the implementation layer has a connection object that opens and closes as...
13
11115
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 writes a specific string to the log file. My original program (MKS Toolkit shell program) which keeps running "grep" checking the "exit string" on...
8
2324
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 still read the old data (if it was read earlier) and this is causing data corruption. WinNT clients inlcuding windows2000 & XP do not have this issue....
2
4829
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 linked tables. There are several users that need access to this db but some get the "Couldn't us <filenameFile already in use" error. Every user has...
5
1921
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. An example query would be something like: Select * from invoices where year 1995 the query must be updatable and only return say 10 to 100...
26
3580
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 corresponding locking file appears in the Windows Explorer view pane as well as expected. Occasionally, a "bare" db1 file (extension only without a...
0
7410
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7668
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7923
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5984
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3466
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.