Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find out whether any file is in use or not

Status
Not open for further replies.

pranavjosh

Programmer
Apr 12, 2001
30
IN
Hi Friends
How to programmatically find out whether the File is in use or not.
 
I was thinking you could try to rename it with RenameFile but I think it would let you if it's in use. You may have to try and move it to a temp dir.

 
try
TFileStream.Create(AFileName, fmOpenRead + fmShareExclusive).Free;
except
on E:EDontDoThatError do
begin
Someone is using it.
end;
end;

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top