Path.Combine is a useful method, but there are edge cases it cannot solve. It can't figure out what you want if what it receives is confusing. But different inputs can yield the same result path.
Next: Here's a screenshot where we combine the folder "Content\\" with the file name "file.txt".
using System; class Program { static void Main() { // // Combine two path parts. // string path1 = System.IO.Path.Combine("Content", "file.txt"); Console.WriteLine(path1); // // Same as above but with a trailing separator. // string path2 = System.IO.Path.Combine("Content\\", "file.txt"); Console.WriteLine(path2); } }
Output
Content\file.txt Content\file.txt
0 comments
Post a Comment