How to manipulate SourceDir path to remove extra backslash

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to manipulate SourceDir path to remove extra backslash

momo
This post has NOT been accepted by the mailing list yet.
This post was updated on .
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.
Loading...