Powershell: 'The fully qualified file name must be less than 260 characters' Powershell: 'The fully qualified file name must be less than 260 characters' powershell powershell

Powershell: 'The fully qualified file name must be less than 260 characters'


As far as I know robocopy deals with this automatically (at least you would have to disable support for long paths explicitly). So you could use

robocopy h:\ g:\ /E

if you're not too adverse to a native command instead of a pure PowerShell solution.

Usually you can prepend \\?\ to a path to allow handling paths with up to 32k characters but it could well be that this might not help with .NET.


On Codeplex Microsoft hosts an experimental long path wrapper which provides functionality to make it easier to work with paths that are longer than the current 259 character limit of the System.IO namespace.

An example of how to copy a file using this wrapper in Powershell:

[reflection.assembly]::loadfile("C:\Users\stackoverflow\Desktop\Microsoft.Experimental.IO.dll")[microsoft.experimental.io.longpathfile]::Copy((gi .\myversion.txt).fullname, "C:\users\stackoverflow\desktop\aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",$true)

Other samples can be found here.