views:

37

answers:

3

Hello

I have a VS2008 windows application project (WinProject) which is deployed by the installation project (InstallationProject) which inturn has the property RemovePreviousVersions set to True.

In my app for each configuration made by an user, the winapp writes the configurations into an xml file (stored in C:\Application Name\Files\ folder) which also includes the path where the config was saved.

Now when I build new versions of the installer,This folder and the files are overwritten since i the flag AlwaysCreate is set to True.

My question is how can i avoid these older files from being overwritten and at the same time shall get the updated file from the installer.

Ex: Contents of the file

  <PriceFiles>
    <Name>arr</Name>
    <Path>C:\NewTool\arr.xml</Path>
    <UserDefined>true</UserDefined>
  </PriceFiles>
  <ReferenceProjects>
    <Name>studio</Name>
    <Path>C:\NewTool\ReferenceProjects\6cd3a9e9-ad65-475e-953b-128915a496cd.xml</Path>
    <UserDefined>true</UserDefined>
    <CreatedBy>Admin</CreatedBy>
  </ReferenceProjects>

Thanks in advance

A: 

Probably you should write your config files to ApplicationData folder. You can get the path to it:

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
Hun1Ahpu
A: 

Is there a reason not to use the built in user configuration settings?

In terms of stopping these files from being overwritten, I don't think there is a way to do it with a default MSI setting.

Do you want to do a merge between the configuration settings already on the machine and the ones being installed and update the config file with any settings that don't exist on the machine? or do you just want to avoid these files being overwritten and have the other parts of the app installed?

The easiest option I can think of would be to not have the config files in the installer at all, and have the application handle that case and create them if it can't find them.

Otherwise you would probably need to do some sort of post-install script that modifies or installs the config files if they don't exist.

One note to make is that my knowledge of MSIs is far from exhaustive, so there could be a way to not overwrite particular files.

Glenn Condron
A: 

Hello Caelum

Yes there is a reason behind for not using the built in Configuration Settings for config my application before installation.

Actually the job i need to perform is both of what you had guessed ... i.e "create the config file with default content if the file don't exist on the machine" "merge the configuration settings if the file is already on the machine "

Should i be using the Custom Installer for this validation ??

Regards Vatsa