Path.Combine loses drive letter


A

aleko

Hi all,

Maybe it's just me, but this seems wrong:

Path.Combine("c:\\", "\\") returns "\\"

I would expect the return to be "c:\\". What do you think?

Thanks,

Aleko
 
Ad

Advertisements

P

Peter Duniho

Maybe it's just me, but this seems wrong:

Path.Combine("c:\\", "\\") returns "\\"

I would expect the return to be "c:\\". What do you think?
Since Path always seems to drop the last \ and since dropping the last
\ on both of those strings results simply in the path "c:", I'd have to
say that without reading the docs I'd expect Path to return "c:".

There must be a good reason why it drops the drive letter, but I don't
know what it is. If you read the documentation literally, it seems to me
that you ought actually to get "c:\\\\", or possibly just "c:\\" (as you
expected). But why it would drop the drive letter, I don't know. Seems
like that's an important part of the path.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top