Home  >  Article  >  Web Front-end  >  JS code to determine whether a file is being used_javascript skills

JS code to determine whether a file is being used_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:07:561124browse

Copy code The code is as follows:

//Determine whether 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('File is in use')
else
ShowMessage('not used');
end;

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn