How to normalize a path in PowerShell?

后端 未结 12 2110
半阙折子戏
半阙折子戏 2020-12-05 03:53

I have two paths:

fred\\frog

and

..\\frag

I can join them together in PowerShell like this:



        
12条回答
  •  天涯浪人
    2020-12-05 04:28

    If you need to get rid of the .. portion, you can use a System.IO.DirectoryInfo object. Use 'fred\frog..\frag' in the constructor. The FullName property will give you the normalized directory name.

    The only drawback is that it will give you the entire path (e.g. c:\test\fred\frag).

提交回复
热议问题