Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

problem in using path.combine statement in c#

Tags:

c#

    string targetPath = @"C:\Program Files\saadhvi\SetupSafetyPADUniversal\";
    string createDatabasesScriptFilePath = Path.Combine(targetPath, "\\EADBScripts\\CreateDatabases.sql");

i am getting the value of createDatabasesScriptFilePath is \EADBScripts\CreateDatabases.sql

but i expected it would be C:\Program Files\saadhvi\SetupSafetyPADUniversal\EADBScripts\CreateDatabases.sql

what is the wrong with my code?

like image 715
Partha Avatar asked Aug 31 '09 10:08

Partha


1 Answers

Here is why your code is returning the 2nd path (copied from MSDN help) -

If path2 does not include a root (for example, if path2 does not start with a separator character or a drive specification), the result is a concatenation of the two paths, with an intervening separator character. If path2 includes a root, path2 is returned.

like image 100
malay Avatar answered Nov 05 '22 16:11

malay