JS code that determines whether the file is being used
- 2020-03-30 00:59:06
- OfStack
//Determine if the file is being used
function FileINUse(filename:String):boolean;
var
usein:file;
begin
result:=false;
assignfile(usein,FileName);
try
reset(Usein);
except
on E:EInOutError do
begin
if e.ErrorCode=32 then
begin
result:=true;
exit;
end;
end;
end;
closefile(usein);
end;
procedure TForm1.Button1Click(Sender: TObject);
if OpenDialog1.Execute then
begin
if fileInuse(OpenDialog1.filename) then
ShowMessage(' The file is in use ')
else
ShowMessage(' Don't use ');
end;