1
votes

I have a folder (database folder) that I would like to keep after uninstall (for saving users data and future reinstall), I have flagged top folder to never uninstall as well as all its files (and folders?) whether empty or not yet Inno Setup deletes these empty sub-folders (which I want to keep) during uninstall. Do I have to declare all the sub folders I want to keep or is their a flag I am missing?

[Dirs]
Name: "{app}\db\data"; Flags: uninsneveruninstall; Permissions: everyone-full

[Files]
Source: "D:\sesam\db\data\*"; DestDir: "{app}\db\data"; Flags: recursesubdirs createallsubdirs uninsneveruninstall; Check: CheckNotExists(ExpandConstant('{app}\db\data'))

Before uninstall and after:

enter image description here enter image description here

As you can see it only keeps "non empty" folders.

1

1 Answers

1
votes

Looks like a bug to me, consider reporting it.


Anyway, you can use the Inno Setup preprocessor to generate a list of [Dirs] entries for each subfolder:

[Dirs]
#define FindHandle
#define FindResult
#define SourceDataPath "D:\sesam\db\data"
#define TargetDataPath "{app}\db\data"

#sub ProcessFoundFile
  #define DirName FindGetFileName(FindHandle)
  #define DirPath SourceDataPath + "\" + DirName
  #if DirExists(DirPath) && (DirName != ".") && (DirName != "..")
    Name: "{#TargetDataPath + "\" + DirName}"; Flags: uninsneveruninstall
  #endif
#endsub

#for {FindHandle = FindResult = FindFirst(SourceDataPath + "\*", faDirectory); \
      FindResult; FindResult = FindNext(FindHandle)} ProcessFoundFile
#expr FindClose(FindHandle)

The above works for single-level only. If you need recursion, it's more complicated.


Put this at the end of your script to see and review, what the preprocessor generated:

#expr SaveToFile(AddBackslash(SourcePath) + "Preprocessed.iss")