260 Character Limit, Get-ChildItem

前端 未结 2 1252
小鲜肉
小鲜肉 2021-01-24 05:54

I understand there is a 260 character limit for win32, but I am curious as to why my code is half working. See below.

$Age_of_Files = -30
$Path = \'\\\\         


        
相关标签:
2条回答
  • 2021-01-24 06:02

    You can turn on long paths in Windows 10. There's a gpo. https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/

    0 讨论(0)
  • 2021-01-24 06:13

    This is a limitation of the Win32 API (see also). There's a PowerShell Module that supposedly works around the issue (haven't used it myself, though).

    A common workaround is to shorten the path by substing the longest accessible path to a drive letter

    & subst X: C:\longest\parent\folder
    

    working on drive X:, then deleting the temporary drive afterwards:

    & subst X: /d
    

    For network paths use net use to the same end:

    & net use X: \\server\share\longest\parent\folder
    ...
    & net use X: /d
    
    0 讨论(0)
提交回复
热议问题