473,666 Members | 2,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3454
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*******@taxu ssi.spamstop.co m.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.c om> wrote in message
news:opskjksqnv d3sg8l@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*******@taxu ssi.spamstop.co m.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.mach in 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
1570
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 03:00 SteveEnt 5 I want to load 'Jim' and '12:00' and those types of answers into variables in my program, the only delimiter in the file is whitespace. How do I do this?
4
8363
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 fails. Second, why the data reader is reading every other record. Here is all of the source code for my little application followed by the contents of the log file that it dumps out:...
1
1567
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 file that Exports info into an MS Access db file and which has 7 Tables (stuff like Project info, Project numbers, User names, etc). I wrote a Time Sheet entry application to read this info and to allow Employees to write their Time Sheet data into...
8
7261
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 (the next pair or bytes and the next etc. specify the second and third values). For example, if I had a file containing 0xff22
30
4570
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
3597
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 that its buffer is bigger than this. I did this expecting the data to be read in one pass.
5
14981
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 and why I have to do it. Hopefully someone has a suggestion... Alright, so I'm using a gps-simulation program that outputs gps data, like longitude, lattitude, altitude, etc. (hundreds of terms, these are just the well known ones). In the newer...
4
2099
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 received (through delegate).
2
2834
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 wireless where I'm working could just be ungodly slow-- which it is.) Is reading a file much more resource/processor intensive than, say, including a .php file? What about the act of creating a simpleXML object? What about the act of checking the...
0
8440
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8352
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8780
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7378
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4192
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4358
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1763
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.