Delphi 判断文件是否被占用,这个在删除的时候,可以添加上此功能,因为文件占用的话,用户删除时会出错,用本代码可以先判断一下文件是否被占用,用弹窗方式告诉用户是否可以删除,如果没有被占用,则程序进行下一步处理。下面简要了解一下判断的具体代码(局部):
on E:EInOutError do
begin
if e.ErrorCode=32 then//文件正在被使用
begin
result:=true;
exit;
end;
end;
更完整的可编译源码,请下载。
SHOW FULL COLUMNS FROM `jrk_downrecords` [ RunTime:0.001034s ]
SELECT `a`.`aid`,`a`.`title`,`a`.`create_time`,`m`.`username` FROM `jrk_downrecords` `a` INNER JOIN `jrk_member` `m` ON `a`.`uid`=`m`.`id` WHERE `a`.`status` = 1 GROUP BY `a`.`aid` ORDER BY `a`.`create_time` DESC LIMIT 10 [ RunTime:0.066513s ]
SHOW FULL COLUMNS FROM `jrk_tagrecords` [ RunTime:0.001090s ]
SELECT * FROM `jrk_tagrecords` WHERE `status` = 1 ORDER BY `num` DESC LIMIT 20 [ RunTime:0.001314s ]
SHOW FULL COLUMNS FROM `jrk_member` [ RunTime:0.000999s ]
SELECT `id`,`username`,`userhead`,`usertime` FROM `jrk_member` WHERE `status` = 1 ORDER BY `usertime` DESC LIMIT 10 [ RunTime:0.003313s ]
SHOW FULL COLUMNS FROM `jrk_searchrecords` [ RunTime:0.001077s ]
SELECT * FROM `jrk_searchrecords` WHERE `status` = 1 ORDER BY `num` DESC LIMIT 5 [ RunTime:0.003836s ]
SELECT aid,title,count(aid) as c FROM `jrk_downrecords` GROUP BY `aid` ORDER BY `c` DESC LIMIT 10 [ RunTime:0.018543s ]
SHOW FULL COLUMNS FROM `jrk_articles` [ RunTime:0.001213s ]
UPDATE `jrk_articles` SET `hits` = 2 WHERE `id` = 293952 [ RunTime:0.021368s ]