According to the official documentation regarding the method Path.Combine: https://msdn.microsoft.com/en-us/library/fyy7a5kt(v=vs.110).aspx
Notes
If path1 is not a disk reference (that is, "C:" or "D:") and does not end with a valid delimiter character, as defined in DirectorySeparatorChar, AltDirectorySeparatorChar or VolumeSeparatorChar, then DirectorySeparatorChar is added to path 1 before concatenation.
This means that it will not be added after the drive letter \, therefore this piece of code:
var path1 = @"c:";
var path2 = @"file.txt";
Path.Combine(path1, path2);
will create C:file.txtthat does not point to the file file.txtlocated at c:.
What is the reason for this?
source
share