user2437443
user2437443

Reputation: 2257

CopyFile not working

I am creating a WiX installer where I want to move a file that exists on the end-user's computer to a location of their choosing. However, CopyFile is not working and the log file is showing no errors.

Here is my Directory Tree:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLFOLDER" Name="Remindex">
    </Directory>
  </Directory>
  <Directory Id="DATALOCATION" Name="File"/>
  <Directory Id="ORIGINALDATA"/>
</Directory>

And my CopyFile component:

<DirectoryRef Id="TARGETDIR">
  <Component Id="CMP_Data" Guid="{C35F8888-D868-4B18-991E-29E217EFE445}" KeyPath="yes">
    <CopyFile Id="CopyData" 
              DestinationDirectory="DATALOCATION" 
              DestinationName="Remindex Local Data" 
              SourceProperty="ORIGINALDATA" 
              SourceName="Remindex Local Data" 
              Delete="yes"/>
  </Component>
</DirectoryRef>

DATALOCATION is a property which contains the path the user chooses in a PathEdit dialog. ORIGINALDATA is the original location of the files to be moved. So the files should be moved from ORIGINALDATA to DATALOCATION. However, nothing is happening. I tried putting ORIGINALDATA in both the SourceDirectory and SourceProperty attributes.

The component shows up three times in the log file (not side by side), although I'm not sure what to make of these entries:

Component: CMP_Data; Installed: Absent; Request: Local; Action: Local

_CMP_Data65; Installed: Null; Request: Local; Action: Local

_CMP_Data66; Installed: Null; Request: Local; Action: Local

Any suggestions would be greatly appreciated.

Upvotes: 0

Views: 1267

Answers (1)

user2437443
user2437443

Reputation: 2257

My problem was that I was trying to copy a folder, when CopyFile only applies to individual files.

To get around this, I will have to manually create each of the subfolders in the folder I wanted to copy, and populate those with the contents of all the old folders. I will use CopyFile and can place a wildcard in the SourceName attribute (SourceName="*") to grab everything from a particular subfolder.

Upvotes: 1

Related Questions