what you shoul do is close it back on every loop and then reopen it on entering back the loop and searching for end-of-file. I know in C, you cant do two consecutive operations on a file, unless you close the file and reopen it first.
is it possible for a file to be open in only a read mode so that it can be edited???
for example i created a program that keeps on reading from a file but when i try to edit the file i get an error [ i am assuming that it is bcuz the program is using the file so it has been lock bcuz when i close teh program i can save it]
this is what i did
File.OpenText(path); this is in a thread that keeps on looping and captures the data
should i have used file.openText ????????????
Processor: Intel(R) Xeon(R) E5520 @2.27GHz 2.26GHz
Memory(RAM): 4GB
HD: 600GB
RAID: 1
what you shoul do is close it back on every loop and then reopen it on entering back the loop and searching for end-of-file. I know in C, you cant do two consecutive operations on a file, unless you close the file and reopen it first.
Psybuck2002us's suggestion will probably fix your problem. I suppose you could also try using a FileStream object which gives you more granular control over things like mode, access and sharing when opening a file.Originally Posted by keroed1
Just out of curiosity are you using the FileSystemWatcher to monitor file changes or do you just have it constantly polling the text file? Is this related to your previous posts about connecting to a serial device?Originally Posted by keroed1
yes it was related to my previous post about a serial device and i found that through file streaming i was able to access the text file as a stream and this work perfectly,
but then i started to think about the volume of data that would be in this text file and i found that looping through a large text file may start to affect program that is running using asystem thread
so i decided to instead let a program write to a database and then i can connect to that database every 2secs read record and then delete it after i have read the record, and then do my modification of the data that was colected.
thus the use of the database instead of a text file allowed me the flexibilty for my three diffewrrent programs to eb connecting to the same data with two to doing both read/write and one jus reading................and the files size to be drastically less so thats pretty much solved at the moment
Processor: Intel(R) Xeon(R) E5520 @2.27GHz 2.26GHz
Memory(RAM): 4GB
HD: 600GB
RAID: 1