I have this powershell:
Get-ChildItem -Path $FileSource | ? {$_.psIsContainer -eq $False}
and Get-ChildItem -Path $FileSource | ? {$_.psIsContainer -eq $True}
which I then use in an array to traverse through the files and folders. This causes an error when the fileshare is over 260 characters. Is there anyway to do the same thing but not get the error?
Asked
Active
Viewed 1,149 times
1

davetherave
- 1,147
- 3
- 10
- 15
-
No, not really. Basically, [.NET can't break the 260 character limit](http://blogs.msdn.com/b/bclteam/archive/2008/07/07/long-paths-in-net-part-3-of-3-redux-kim-hamilton.aspx) because it's built on Win32, and Win32 is terrible at supporting breaking the 260 character limit because 30 years ago MS promised it would never have a path longer than 260 characters. There are a ton of hacks out there to get around it that you can find with a Google search, but many of them aren't useful since you can't use a long path with another cmdlet. – Bacon Bits Aug 04 '15 at 20:04
1 Answers
0
As suggested at How to avoid System.IO.PathTooLongException? you may use 3rd party library such as Delimon.Win32.IO.
Example code:
Add-Type -Path "D:\temp\Delimon.Win32.IO.dll"
[Delimon.Win32.IO.Directory]::GetFiles("\\longpath")
[Delimon.Win32.IO.Directory]::GetDirectories("\\longpath")