Rich Cooper wrote:
<snipz>
>>> Does anyone have a way to determine whether the file HARBOR.TXT
>>> has been released for reading after being completely written?  I would
>>> be able to fix this problem by replacing the Sleep(500) with a loop
>>> that tests till the HARBOR.TXT file is ready for reading, having been
>>> fully released.

>> I don't know precisely how cmd.exe creates and opens a redirected file
>> like that, but your attempting to open it in "exclusive share" mode
>> ought to fail regardless if the file is still being written.
>>
>> You can use a TFileStream instance, like so:
>>
>>   FS := TFileStream.Create(D + 'HARBOR.TXT',
>>    fmOpenRead or fmShareExclusive);
>>
>> Attempt that and catch any exception raised due to the sharing conflict
>> (should be some form of EInOutError), if the file exists and no
>> exception is raised on attempting to open it, then it should be finished.
>>
>> HTH
>>
>> Stephen Posey
>> [EMAIL PROTECTED]
> 
> I tried "LoadFromFile()" with try ... except end around it and kept
> looping till the exceptions went away - that worked just fine!
> 
> Thanks Stephen and Simon,

Glad you got it working.

Stephen Posey
[EMAIL PROTECTED]

_______________________________________________
Delphi mailing list -> Delphi@elists.org
http://www.elists.org/mailman/listinfo/delphi

Reply via email to