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

Put standard output into file

Hi All,

My application puts standard output from command line(using process.start())
into a file on the hard disk then reads the info from that file after
command has finished. The problem is my program keep giving me the error
message saying that output file doesn't exits on the hard disk, but it's
there when I checked in the directory. I think there must be a delay on put
output file on the hard disk.

I am just wondering if anyone has solution for this type of problem except
using System.Threading.Thread.Sleep function. Any help is great appreciate.

Thanks in advance

Alan
Jan 12 '06 #1
6 1711
Alan Wang wrote:
Hi All,

My application puts standard output from command line(using process.start())
into a file on the hard disk then reads the info from that file after
command has finished. The problem is my program keep giving me the error
message saying that output file doesn't exits on the hard disk, but it's
there when I checked in the directory. I think there must be a delay on put
output file on the hard disk.

I am just wondering if anyone has solution for this type of problem except
using System.Threading.Thread.Sleep function. Any help is great appreciate.

Thanks in advance

Alan


Have you looked at using the FileSystemWatcher class to watch for when
your file is created? This will fire and event when the file is there.

There are lots of examples on using it. One is:
http://www.codeproject.com/csharp/fswatcher.asp

Chris
Jan 12 '06 #2
Alan Wang wrote:
My application puts standard output from command line(using
process.start()) into a file on the hard disk then reads the info
from that file after command has finished. The problem is my program
keep giving me the error message saying that output file doesn't
exits on the hard disk, but it's there when I checked in the
directory. I think there must be a delay on put output file on the
hard disk.


Are you sure you're using the full (and correct!) path when you try to read
the file?

Andrew
Jan 12 '06 #3
I am pretty sure I am using the right path because I didn't get problem when
I run the program in debugging mode because it has enough time to write data
back to the hard disk.

Alan
"Andrew Morton" <ak*@in-press.co.uk.invalid> wrote in message
news:Ow**************@TK2MSFTNGP12.phx.gbl...
Alan Wang wrote:
My application puts standard output from command line(using
process.start()) into a file on the hard disk then reads the info
from that file after command has finished. The problem is my program
keep giving me the error message saying that output file doesn't
exits on the hard disk, but it's there when I checked in the
directory. I think there must be a delay on put output file on the
hard disk.


Are you sure you're using the full (and correct!) path when you try to
read the file?

Andrew

Jan 12 '06 #4
The problem is FileSystemWatcher doesn't tell me when output file is ready
to be processed. In another words, I don't know how long I should wait to do
next step.

Alan
"Chris" <no@spam.com> wrote in message
news:uL**************@TK2MSFTNGP09.phx.gbl...
Alan Wang wrote:
Hi All,

My application puts standard output from command line(using
process.start()) into a file on the hard disk then reads the info from
that file after command has finished. The problem is my program keep
giving me the error message saying that output file doesn't exits on the
hard disk, but it's there when I checked in the directory. I think there
must be a delay on put output file on the hard disk.

I am just wondering if anyone has solution for this type of problem
except using System.Threading.Thread.Sleep function. Any help is great
appreciate.

Thanks in advance

Alan


Have you looked at using the FileSystemWatcher class to watch for when
your file is created? This will fire and event when the file is there.

There are lots of examples on using it. One is:
http://www.codeproject.com/csharp/fswatcher.asp

Chris

Jan 12 '06 #5
Alan Wang wrote:
I am pretty sure I am using the right path because I didn't get
problem when I run the program in debugging mode because it has
enough time to write data back to the hard disk.


"Pretty sure" just doesn't cut it. How about putting up a message box with
the path in?
Or you could use filemon from www.sysinternals.com to see in what order the
activity associated with your file happens.
Otherwise you could check the length of the file and when it hasn't
increased for perhaps 500ms then try to read it?

Andrew

--
PS: You might like to use OE-Quotefix so that your Outlook Express replies
in the conventional format.
Jan 13 '06 #6
Why do you put it into a file, rather than reading straight from the memory
stream? Have you read through
http://msdn2.microsoft.com/en-us/lib...ardoutput.aspx ?
Jevon
"Alan Wang" <wa**@vdata.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi All,

My application puts standard output from command line(using
process.start()) into a file on the hard disk then reads the info from
that file after command has finished. The problem is my program keep
giving me the error message saying that output file doesn't exits on the
hard disk, but it's there when I checked in the directory. I think there
must be a delay on put output file on the hard disk.

I am just wondering if anyone has solution for this type of problem except
using System.Threading.Thread.Sleep function. Any help is great
appreciate.

Thanks in advance

Alan

Jan 13 '06 #7

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

Similar topics

8
by: Marko Faldix | last post by:
Hello, with Python 2.3 I can write umlauts (a,o,u umlaut) to a file with this piece of code: import codecs f = codecs.open("klotentest.txt", "w", "latin-1") print >>f, unicode("My umlauts...
7
by: Steven T. Hatton | last post by:
I haven't looked very closely, but from what I'm seeing, it looks like there are no buffered I/O streams in the Standard Library. There are stream buffers, but not buffered streams. I don't have...
5
by: francescomoi | last post by:
Hi. Using PHP 4.3.11, I want my script not to write standard output on the webpage, but on a textfile. I tried with: $variableName = 44;
3
by: beliavsky | last post by:
I want to write a function that writes to an output file if specified and otherwise to standard output. How can I connect a file object to standard output in the code below? I could use an if...
2
by: Devine123 | last post by:
Hi, I’m creating a perl script that takes incoming http/s requests, logs the standard input, output and error, before returning the output to the client. The input, output and error log is appended...
270
by: jacob navia | last post by:
In my "Happy Christmas" message, I proposed a function to read a file into a RAM buffer and return that buffer or NULL if the file doesn't exist or some other error is found. It is interesting...
14
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my windows applicationm, i need to excute a batch file. this batch file throws some text and questions to the screen, i need to catch the standard Output, check if it's a question, in...
3
by: sab | last post by:
Hello, I have been working on a python script to parse a continuously growing log file on a UNIX server. The input is the standard in, piped in from the log file. The application works well...
1
by: TP | last post by:
Hi everybody, I try to find a quick way to redirect the standard output of a Python command (for example: print "message") to a python variable "foobar". Ok, in this simple example, I could do...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.