C# Best way to get folder depth for a given path?

后端 未结 7 2051
野趣味
野趣味 2021-02-19 18:29

I\'m working on something that requires traversing through the file system and for any given path, I need to know how \'deep\' I am in the folder structure. Here\'s what I\'m cu

7条回答
  •  故里飘歌
    2021-02-19 19:11

    I'm more than late on this but I wanted to point out Paul Sonier's answer is probably the shortest but should be:

     Path.GetFullPath(tmpPath).Split(Path.DirectorySeparatorChar).Length;
    

提交回复
热议问题