编译此函数时没有响应?
我尝试使用 Delphi XE,但编译时没有响应。它在您的计算机上可以运行还是功能有问题?
function Test(const FileName: string;
const Force: boolean = false): boolean;
var
IsAllowed: boolean;
begin
result := false;
if FileExists(FileName) then
begin
try
if (Force) then
begin
result := false;
exit;
end;
finally
if IsAllowed then
DeleteFile(FileName);
end;
try
result := true;
except
result := false;
end;
end;
end;
I tried with Delphi XE and I got Not Responding while compiling. Does it work in your computer or is there something wrong with the function?
function Test(const FileName: string;
const Force: boolean = false): boolean;
var
IsAllowed: boolean;
begin
result := false;
if FileExists(FileName) then
begin
try
if (Force) then
begin
result := false;
exit;
end;
finally
if IsAllowed then
DeleteFile(FileName);
end;
try
result := true;
except
result := false;
end;
end;
end;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它在我的电脑上编译。虽然我收到警告 W1036 变量“IsAllowed”可能尚未初始化。
更新:当我在 use 子句中包含 Windows 时,我可以重现挂起。
已提交到质量中心:QC93806。
看起来像一个错误;您应该在质量中心中报告该问题。
更新 2:可重复挂起编译器的最小情况:
It compiles on my computer. Though I get the warning W1036 Variable 'IsAllowed' might not have been initialized.
Update: I can reproduce the hang when I include Windows in the uses clause.
Subbmitted to Quality Central: QC93806.
It looks like a bug; you should report it in the Quality Central.
Update 2: Minimal case which reproducibly hangs the compiler: