Should a directory path variable end with a trailing slash?

前端 未结 12 2025
暖寄归人
暖寄归人 2020-12-24 04:33

When defining a path to a directory as a variable or constant, should it end with a trailing slash? What is the convention?

pwd in Unix shows your curre

12条回答
  •  时光取名叫无心
    2020-12-24 05:04

    I've never seen a firm convention either way.

    Pretty sure, though, that whatever you settle upon, someone else will be 100% sure it should be the other way. So, the best idea is to tolerate things being set either way.

    In the .NET world, Path.Combine() gives you a way to handle this - there are equivalents in other environments, from cmd files on up.

提交回复
热议问题