|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Put standard output into fileHi 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 Alan Wang wrote:
Show quoteHide quote > Hi All, Have you looked at using the FileSystemWatcher class to watch for when > > 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 > > 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 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 Show quoteHide quote "Chris" <no@spam.com> wrote in message news:uLBWYe5FGHA.1180@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 Alan Wang wrote:
> My application puts standard output from command line(using Are you sure you're using the full (and correct!) path when you try to read > 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. the file? Andrew 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 Show quoteHide quote "Andrew Morton" <a**@in-press.co.uk.invalid> wrote in message news:OwHvzx5FGHA.3856@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 > Alan Wang wrote:
> I am pretty sure I am using the right path because I didn't get "Pretty sure" just doesn't cut it. How about putting up a message box with > problem when I run the program in debugging mode because it has > enough time to write data back to the hard disk. 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. 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/library/system.diagnostics.process.standardoutput.aspx ? Jevon Show quoteHide quote "Alan Wang" <w***@vdata.com> wrote in message news:%23PkBby4FGHA.1676@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 >
VS2003 to VS2005 Conversion
Email attachments? Module and Class Probably an intro question -> starting window over? calling form_load? Copying DataRows to another DataTable win32 dll vb.net pointers receiving data - HELP Spell checker modal dialog box Running app on Shared Drive Locking Application to HDD Sr.No. |
|||||||||||||||||||||||