是否有方法查看是否正在使用tfile流的instance? 例如,如果我声明tfilestream类型的fs,则向它写入缓冲区,然后 最后,使用tfilestream释放流。free我可以检查一下吗? 像:
if tfilestream.NotActive then //code if tfilestream.beingused then //code if tfilestream.free = true then //code
积极的 和 被使用的 方法不存在于实际中,我们也无法测试 tfilestream.free=真 只是为了表达我想问的问题
你不能像你期望的那样去做。但是你和你一起做 FreeAndNil()
FreeAndNil()
var FS : TFileStream; begin FS := TFileStream.Create(...); try // Do Work with TFileSTream finally FreeAndNil(FS); end; // For some reason you need to check FS is freed. if not Assigned(FS) then begin // Stream was freed. end; end;