turnerrob
asked on
Opening a File to Read (Allready Open By Another Program)
I am reading files from a directory , the files in this directory are being generated by another program (not written by me), I do not know what language it is written in. (but the program is pretty old)
This other program refreshes the same file name with new data, approx every 20 seconds.
The problem i am having is.. My vb program opens the file for input, reads the data and then closes. If i am in the middle of reading the file and the other program tries to rewrite the file, the other program bombs out with a system error.
Have tried.. renaming,copying etc (everything!!) .. the file i need, but still strike the problem.
Am thinking i will have to look at the time of the file and calculate the safest time to read the file????
Is there any other way of overcoming the problem., other than the above idea
Appreciate any ideas!!!
This other program refreshes the same file name with new data, approx every 20 seconds.
The problem i am having is.. My vb program opens the file for input, reads the data and then closes. If i am in the middle of reading the file and the other program tries to rewrite the file, the other program bombs out with a system error.
Have tried.. renaming,copying etc (everything!!) .. the file i need, but still strike the problem.
Am thinking i will have to look at the time of the file and calculate the safest time to read the file????
Is there any other way of overcoming the problem., other than the above idea
Appreciate any ideas!!!
You mentioned copying, but did you copy the file to a new location and then read from the copy? You can copy the file, read the data and close the file, the other program shouldn't bomb this way.
ASKER
I have tried using filecopy , and copy to another directory etc.
If i use filecopy and the other program tries to write over the top, it bombs out.
If i use filecopy and the other program tries to write over the top, it bombs out.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think this is the case, ie the old program is opening (exclusive)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
_agj_
I agree this is my only option.
I only put the question, in case, there was some magic method of overcoming reading an (exclusive open) file.
Looks like there is none????
I agree this is my only option.
I only put the question, in case, there was some magic method of overcoming reading an (exclusive open) file.
Looks like there is none????
hey, if there were a way to read an exclusively open file, then wudnt it cease to be 'exclusive' :D
ASKER
appreciate the help offered.
sorry i left the question open for so long
sorry i left the question open for so long
http://www.mentalis.org/apilist/CopyFile.shtml
Idle_Mind