2014-10-27 297 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'));