2014-10-27 291 views
1

我在InnoTools Downloader上使用Inno Setup,下載完成後我想將下載的文件複製到選定的目錄中。Inno Setup - 文件複製

if CurStep=ssPostInstall then begin 
    FileCopy('Test.exe', ExpandConstant('{app}\Test.exe'), False); 

它沒有做任何事情,但如果我重新啓動安裝程序,我重新安裝到同一個文件夾中,那麼它的複製文件。這怎麼可能或者我做錯了什麼?如果我只是這樣做,那麼它正常工作,每次:

if CurStep=ssPostInstall then begin 
    FileCopy('Test.exe', 'Test1.exe', False); 
+0

指定的完整路徑,第一個參數('ExistingFile')爲好。給它下載文件的完整路徑。否則,你期望你的源文件被放置在當前目錄中(例如由'GetCurrentDir'函數返回的路徑)。 – TLama 2014-10-27 16:08:16

+0

感謝您的快速回答,但是您能否告訴我如何將文件直接下載到選定的目錄?我將這個文件添加到這個部分的下載器:InitializeWizard,但是我不能在這裏使用{app},因爲它尚未初始化。代碼部分在路徑選擇之後在哪裏? – YolmieK 2014-10-27 16:08:36

回答

0

我解決了使用{src]的constans:

// Add the file 
itd_addfile('http://test.com/Test.exe',ExpandConstant('{src}\Test.exe')); 

// Copy the file when it's finished the download 
FileCopy(ExpandConstant('{src}\Test.exe'), ExpandConstant('{app}\Test.exe'), False); 
// Delete the old file 
DeleteFile(ExpandConstant('{src}\Test.exe'));