2014-03-01 42 views
3

我不知道,如果我要問了,這是可能的,但無論如何,我來到這裏:Inno Setup的:檢查組件是之前下載的

我有一個使用下面的代碼的Inno下載插件:

procedure CurPageChanged(CurPageID: Integer); 
begin 
    if CurPageID = wpReady then 
    begin 
    idpClearFiles; 
    if IsComponentSelected('src') then 
    begin 
     idpAddFile(
     'https://cool-opensource-project.googlecode.com/files/prj-sources-1.2.3.zip', 
     ExpandConstant('{tmp}\src.zip')); 
    end; 
    end; 
end; 

,我想檢查,如果該文件的文件夾中重新下載之前已經下載,如果實在不行,下載它。

謝謝先進。

回答

1

您可以通過FileExists函數檢查文件是否存在。在你的情況下,它會是這樣的:

procedure CurPageChanged(CurPageID: Integer); 
var 
    FileName: string; 
begin 
    if CurPageID = wpReady then 
    begin 
    idpClearFiles; 
    { better use a local variable to avoid expanding the same path twice } 
    FileName := ExpandConstant('{tmp}\src.zip'); 
    { if the component item is checked and file does not exist yet, enqueue it } 
    if IsComponentSelected('src') and not FileExists(FileName) then 
    begin 
     idpAddFile(
     'https://cool-opensource-project.googlecode.com/files/prj-sources-1.2.3.zip', 
     FileName); 
    end; 
    end; 
end; 
+0

令人驚歎!它完美的工作!非常感謝你的一切,併爲我的快速回復。 – DeXon

+0

不客氣! – TLama