I have the following command:
string reportedContentFolderPath =
Path.Combine(contentFolder.FullName.ToString(), @"\ReportedContent\");
When I look in the debugger I can see the following:
contentFolder.FullName = "E:\\"
However
reportedContentFolderPath = "\\ReportedContent\\"
Why is the Path.Combine
chopping off the E:\?
The combined paths. If one of the specified paths is a zero-length string, this method returns the other path. If path2 contains an absolute path, this method returns path2 .
Path. Combine uses the Path. PathSeparator and it checks whether the first path has already a separator at the end so it will not duplicate the separators.
You have a leading slash on @"\ReportedContent\"
. You don't want that (or the trailing one, I suspect) - try just:
string reportedContentFolderPath =
Path.Combine(contentFolder.FullName.ToString(), "ReportedContent");
From the documentation:
If
path2
does not include a root (for example, ifpath2
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. Ifpath2
includes a root,path2
is returned.
In your case, path2
did contain a root, so it was returned without looking at path1
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With