tags:

views:

137

answers:

3

Hi

Let us have a path

C:\Program Files\TestFolder

this path i got programatically and stored in a varible dirpath(for example)
Now i have concatinated string

dirpath=getInstallationpath()+"\\ test.dll /codebase /tlb";

then dirpath is become

C:\Program Files\TestFolder\test.dll /codebase /tlb

But my problem is i have make the path enclosed in double quotes

"C:\Program Files\TestFolder\test.dll"

Because when i directly pass the dirpath as commandline for regasm in a CreateProcess() then it should accept for C:\Program only because of white spaces.so i tried lot of stunts like

dirpath="\ "+getInstallationPath()+" \test.dll /codebase /tlb "

like that but did not worked...

So please Hep me in this regard...

Thanks in Advance...

+2  A: 

I believe you forgot the second \" after test.dll

A.Rashad
+2  A: 

I can see two issues with that line. First of all, you need to escape the backslash preceding test.dll. Secondly, wrapping the path in quotation marks requires that you also escape the quotation marks.

After these changes, it should look like this:

dirpath="\""+getInstallationPath()+"\\test.dll\" /codebase /tlb "

Edit:

Fixed the assignment per Martin's request. Forgot a closing quotation mark for the first string!

Eric
It compiles under g++ with dirpath as a string.
Eric
+2  A: 

For building complex strings it is usually easier (and more effecient) to use a string stream.

// Note the character(") and the character(\)
// will need to be escaped when used inside a string
std::stringstream  stuff;
suff << "\"" 
     << getInstallationPath() << "\\test.dll" 
     << "\""
     << "/codebase /tlb";
                                                //
dirpath = stuff.str();
Martin York
Thank u very Much.......
Cute