473,388 Members | 1,230 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,388 software developers and data experts.

Reading file every 1 second


Hello,

I would like to read file during runtime(the other third party vendor
write the program and my program read it every second). I can't do it
until the third party vendor stop writing it. anyone can help?

Sincerely Yours,
Pujo
--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 16 '05 #1
4 3445
Hi,

FileStream constructor has a FileShare parameter.
I believe that setting it to "ReadWrite" allow you to
access read/write operation.
But there can be problem if "third party vendor" doesn't
allow to share that file.

HTH
Marcin
Hello,

I would like to read file during runtime(the other third party vendor
write the program and my program read it every second). I can't do it
until the third party vendor stop writing it. anyone can help?

Sincerely Yours,
Pujo

Nov 16 '05 #2
Hi,

I think the third party vendor give the access, since I can open using
notepad and see the difference every 1 second.
I use this code before:
string sLN;
try {
using (TextReader tr = new StreamReader(FN)) {
sLN = tr.ReadLine();
while (sLN != null) {
//show in console
sLN = tr.ReadLine();
}
tr.Close();
}
}
catch {
//give some info;
}

How can I use the FileStream, FileShare parameter?

Sincerely Yours,
Pujo Aji

On Thu, 13 Jan 2005 13:37:42 +0100, Marcin Grzębski
<mg*******@taxussi.spamstop.com.spamstop.pl> wrote:
Hi,

FileStream constructor has a FileShare parameter.
I believe that setting it to "ReadWrite" allow you to
access read/write operation.
But there can be problem if "third party vendor" doesn't
allow to share that file.

HTH
Marcin
Hello,
I would like to read file during runtime(the other third party vendor
write the program and my program read it every second). I can't do it
until the third party vendor stop writing it. anyone can help?
Sincerely Yours,
Pujo


--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 16 '05 #3
Hi,

Use a FileStream and decorate it with a StreamReader:

FileStream fs = new FileStream( file , FileMode.Open, FileAccess.Read )
StreamReader reader = new StreamReader( fs)

it may solve your problem.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Pujo Aji" <aj****@yahoo.com> wrote in message
news:opskjksqnvd3sg8l@ajinote...
Hi,

I think the third party vendor give the access, since I can open using
notepad and see the difference every 1 second.
I use this code before:
string sLN;
try {
using (TextReader tr = new StreamReader(FN)) {
sLN = tr.ReadLine();
while (sLN != null) {
//show in console
sLN = tr.ReadLine();
}
tr.Close();
}
}
catch {
//give some info;
}

How can I use the FileStream, FileShare parameter?

Sincerely Yours,
Pujo Aji

On Thu, 13 Jan 2005 13:37:42 +0100, Marcin Grzebski
<mg*******@taxussi.spamstop.com.spamstop.pl> wrote:
Hi,

FileStream constructor has a FileShare parameter.
I believe that setting it to "ReadWrite" allow you to
access read/write operation.
But there can be problem if "third party vendor" doesn't
allow to share that file.

HTH
Marcin
Hello,
I would like to read file during runtime(the other third party vendor
write the program and my program read it every second). I can't do it
until the third party vendor stop writing it. anyone can help?
Sincerely Yours,
Pujo


--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 16 '05 #4
Hi,

I tried to implement your suggestion into my code:
string sLN;
try{
FileStream fs = new FileStream(File,FileMode.Open,FileAccess.Read);
StreamReader reader = new StreamReader(fs);
sLN = reader.ReadLine();
while (sLN != null) {
//write to console
sLN = reader.ReadLine();
}
}
catch{
//Information
}

It doesn't work, the result is the same.Am I missing something?

Pujo

On Thu, 13 Jan 2005 09:33:46 -0500, Ignacio Machin ( .NET/ C# MVP )
<ignacio.machin AT dot.state.fl.us> wrote:
Hi,

Use a FileStream and decorate it with a StreamReader:

FileStream fs = new FileStream( file , FileMode.Open, FileAccess.Read )
StreamReader reader = new StreamReader( fs)

it may solve your problem.

cheers,


--
Baby Step, One Step at a time, better and better....
Nov 16 '05 #5

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

Similar topics

8
by: Uri | last post by:
I have a file that looks like this: (but longer, no wordwrap) Name: Date: Time: Company: Employee Number: Jim 2.03.04 12:00 JimEnt 4 Steve 3.04.32 ...
4
by: Jason Kumpf | last post by:
OK I've been staring at this code all day and still with everything I have tried I cannot figure out two problems I am having. Once is why the space limit for the directory I create in the code...
1
by: Mr. B | last post by:
VB.net 2003 c/w Framework 1.1 and MS Access db We have a commercial program that does our Acounting and Time Sheets (Timberline). At least once a day our Accounting department runs a Script...
8
by: junk5 | last post by:
Hi I need to read raw 16 bit data from a file, where the first byte is the most significant byte of the first data value and the second byte is the least significant byte of the first data value...
30
by: siliconwafer | last post by:
Hi All, I want to know tht how can one Stop reading a file in C (e.g a Hex file)with no 'EOF'?
9
by: Macca | last post by:
Hi, I have a synchronous socket server which my app uses to read data from clients. To test this I have a simulated client that sends 100 byte packets. I have set up the socket server so...
5
blazedaces
by: blazedaces | last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing...
4
by: Shark | last post by:
Hi, I need a help. My application reads data from COM port, this data is then parsed and displyed on: 1. two plotters 2. text box. I'm using Invoke method to update UI when new data is...
2
by: Derik | last post by:
I've got a XML file I read using a file_get_contents and turn into a simpleXML node every time index.php loads. I suspect this is causing a noticeable lag in my page-execution time. (Or the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...

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.