What is the advantage of using Path.Combine over concatenating strings with '+'?

后端 未结 5 475
情深已故
情深已故 2020-11-30 10:53

I don\'t quite see the difference.

What could Path.Combine do better than perfectly working string concatenation?

I guess it\'s doing something

5条回答
  •  悲哀的现实
    2020-11-30 11:27

    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. Additionally, it checks whether the path elements to combine have invalid chars.

提交回复
热议问题