Why does Path.Combine produce this result with a relative path?

Drop the leading slash on relativePath and it should work.

The reason why this happens is that Path.Combine is interpreting relativePath as a rooted (absolute) path because, in this case, it begins with a \. You can check if a path is relative or rooted by using Path.IsRooted().

From the doc:

If the one of the subsequent paths is
an absolute path, then the combine
operation resets starting with that
absolute path, discarding all previous
combined paths.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)