[wix-users] How to manipulate SourceDir path to remove extra backslash

Momo Popo momo12march at yahoo.com
Mon Aug 31 23:11:11 PDT 2015


I am using [SourceDir] way to get the path to the running MSI. 

<Property Id="MsiDirectory" Value="[SourceDir]"/>  

In my custom action, I try to copy a file to the MsiDirectory. 

string msiDirectory = session["MsiDirectory"]; 
string fileName = "destinationFile.txt"; 

string newFile = System.IO.Path.Combine(@msiDirectory , @fileName); 
newFile = newFile .Replace(@"\\", @"\"); 
session.Log("copied to: {0}", @newFile ); 

The msi is being run from C:\temp 

The log shows copied to C:\temp\\destinationFile.txt 

I have tried using Trim.End, stringbuilder.Remove and other suggestions, but nothing seems to be removing the extra \ added after the temp.  Can anyone help please.


More information about the wix-users mailing list