Home > Article > Web Front-end > JS code to determine whether a file is being used_javascript skills
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('File is in use')
else
ShowMessage('not used');
end;