Discussion:
How to delete a file if it exist
(too old to reply)
Philippe MESMEUR
2009-09-07 09:04:46 UTC
Hi everybody,

In my merge module file system, I have an XML file (let's say
FooBarSource.xml) whose properties are:
Exclude: False
Folder: MyFolder
Hidden: False
PackageAs: vsdpaDefault
Permanent: False
Register: vsdrfDoNotRegister
SharedLegacyFile: False
SourcePath: c:\FooBarSource.xml
System: False
TagetName: FooBarTarget.xml
Transitive: False
Vital: True

It is possible that, when my setup is launched, the file
FooBarTarget.xml already exists. In that case, I want that it is
deleted and FooBarTarget.xml embedded in my setup is installed.

In fact, what happens is that the file that already existing remains
on the file system and the one I wanted to be installed is not
installed at all...

Can you please tell me what can I do? Have I to modify the properties
of my file? Have I to do something else?
Thank you very much for your help

Philippe Mesmeur
Wilson, Phil
2009-09-09 18:13:48 UTC
There are no features in Visual Studio setup projects that allow you to
delete a file or run code before the files are installed, and all install
custom actions are run after files are installed.

If the file isn't being replaced, then that'll be because it looks like it
has been updated, and the default file update rules are that updated data
files aren't replaced. You wouldn't want everything in some database to be
replaced with an empty one from an install! Given the way that VS setup
projects work, I'd use an install custom action to make sure that the Xml
file is correct (it will run after the files have been installed) then you
can see whether your file has been installed, and if not you can update the
Xml with whatever needs adding (or deleting etc).
--
Phil Wilson
The Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972
Post by Philippe MESMEUR
Hi everybody,
In my merge module file system, I have an XML file (let's say
Exclude: False
Folder: MyFolder
Hidden: False
PackageAs: vsdpaDefault
Permanent: False
Register: vsdrfDoNotRegister
SharedLegacyFile: False
SourcePath: c:\FooBarSource.xml
System: False
TagetName: FooBarTarget.xml
Transitive: False
Vital: True
It is possible that, when my setup is launched, the file
FooBarTarget.xml already exists. In that case, I want that it is
deleted and FooBarTarget.xml embedded in my setup is installed.
In fact, what happens is that the file that already existing remains
on the file system and the one I wanted to be installed is not
installed at all...
Can you please tell me what can I do? Have I to modify the properties
of my file? Have I to do something else?
Thank you very much for your help
Philippe Mesmeur