Get all files in folder including those with long (>256 characters) path + name

后端 未结 3 1319
别那么骄傲
别那么骄傲 2021-01-15 08:11

I\'m trying to build a comma separated list of file names in a specific folder. These files tend to have long names (they\'re test case results and the name is very descript

3条回答
  •  心在旅途
    2021-01-15 09:06

    This seems to be a really popular question because it has been asked multiple times on this site.Anyway here are your alternatives:

    Use Pinvoke

    Boe Prox - Technet

    Use Robocopy

    Boe Prox - Technet

    Use AlphaFS with Powershell V5 and V4

    if you can find a computer with PowerShell v5 (windows 10 comes with PS v5) you can install a module called PSAlphaFS .

    Install-Module PSAlphaFS
    

    by default the modules from powershellgallery get installed to

    C:\Program Files\WindowsPowerShell\Modules
    

    Note:The PSAlphaFS module can also be run on a target system with PowerShell V4 but not on powershell V3.

    Here is how you can find out the version of Powershell that is currently running.

    $PSVersionTable.PSVersion
    

    Once the module is in place you can then run the following command which is similar to get-childitem but without the 260 char limitation.

    Get-LongChildItem  -Filter *.txt -Name
    

提交回复
热议问题