puneet
puneet

Reputation: 622

Take backup of files from destination folder before installing in Inno Setup

I am using the Inno setup to copy some files from the source directory on my desktop to a folder in the destination computer where I run the Inno Setup. However, before I actually start transferring the files, I wish to take the backup of certain files that will eventually be overwritten.

I am using the [Files] section of Inno setup to set the source and destination location

Source: "{#MyLocalDir}\Controller\bin\Release\*"; \
    DestDir: "{app}\Controller"; \
    Flags: ignoreversion recursesubdirs createallsubdirs;

This works absolutely fine, however, I wish to take the backup of some files from the destination folder into another directory in the destination folder to perform some audit on the file. I use the below code and it doesn't work

Source: "{app}\Controller\Controller.exe.config"; \
    DestDir: "{app}\PrevVersion\Controller\Controller.exe.config"; \
    Flags: ignoreversion recursesubdirs createallsubdirs;

It gives the error that the location doesn't exist. Please help

Upvotes: 2

Views: 221

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202088

If you want to copy files from the destination machine (as opposite to installing files from the source machine [the machine where you compile the installer]), you have to use external flag. That also allows you to use constants (such as {app}) in the Source parameter.

[Files]
Source: "{app}\Controller\Controller.exe.config"; \
    DestDir: "{app}\PrevVersion\Controller\Controller.exe.config"; \
    Flags: external ignoreversion recursesubdirs createallsubdirs

Upvotes: 2

Related Questions