Powershell:“标准文件名必须少于260个字符" [英] Powershell: 'The fully qualified file name must be less than 260 characters'

查看:211
本文介绍了Powershell:“标准文件名必须少于260个字符"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用powershell命令copy-item作为xcopy来将一个磁盘的内容复制到另一磁盘.

I tried to use powershell command copy-item as xcopyto copy content of one disk to another one.

copy-item -Path h:\* -Destination g:\ -Recurse -Force

但是,我遇到以下错误:

However, I encountered the following errors:

Copy-Item:指定的路径,文件名或两者都太长.这 标准文件名必须少于260个字符,并且 目录名称必须少于248个字符.

Copy-Item : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

我得到的这些错误足以阻止手动搜索和复制路径较长的文件或文件夹.避免此问题的最佳方法是什么?

I got these errors enough to discourage manually search and copy files or folders with long paths. What is the best way to avoid this problem?

推荐答案

据我所知,robocopy会自动处理此问题(至少您必须显式禁用对长路径的支持).所以你可以使用

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

如果您不太反对本机命令而不是纯PowerShell解决方案.

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

通常,您可以在\\?\之前添加路径,以允许处理最多32k个字符的路径,但这很可能对.NET无效.

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.

这篇关于Powershell:“标准文件名必须少于260个字符"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆