PathTooLongException C# 4.5 [英] PathTooLongException C# 4.5

查看:32
本文介绍了PathTooLongException C# 4.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法复制一些文件夹 260+ 个字符(例如:F:NNNNNNNNNNNNNNNNNNNNNNNNNNNROOT$RECYCLE.BINS-1-5-21-3299053755-4209892151-505108915-1L3008NNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNpublishApplication FilesTNNNNNNNNNNNN_1_0_0_0NNNNNNNNNNNN.exe.manifest) 到其他地方,并带有标准的 DrectoryInfo.Create();添加 ? 或 ?UNC(如\?UNC")只会抛出另一个 ArgumentException.我究竟做错了什么?不使用 Directory.SetCurrentDirectory() 我还能做什么?

I having trouble of copying some folder 260+ chars (for example: F:NNNNNNNNNNNNNNNNNNNNNNNNNNNROOT$RECYCLE.BINS-1-5-21-3299053755-4209892151-505108915-1000$RMSL3U8NNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNpublishApplication FilesTNNNNNNNNNNNN_1_0_0_0NNNNNNNNNNNN.exe.manifest) to some other place with standart DrectoryInfo.Create(); adding ? or ?UNC (like "\?UNC") just throw another ArgumentException. What am i doing wrong? What else i can do without using Directory.SetCurrentDirectory() ?

推荐答案

是的,使用标准 API 会给您带来这种限制(255 个字符的 IIRC).

Yes, using the standard APIs will give you this kind of limitations (255 chars IIRC).

在 .NET 中,您可以使用 AlphaFS 项目,它允许您使用很长的路径(使用\?" 样式)并模仿 System.IO 命名空间.

From .NET you can use the AlphaFS project which lets you use very long paths (using the "\?" style) and mimics the System.IO namespace.

您可能可以像使用 System.IO 一样使用此库,例如:AlphaFS.Win32.Filesystem.File.Copy() 代替 System.IO.File.Copy()

You will probably be able to use this library just as if you were using System.IO, for example : AlphaFS.Win32.Filesystem.File.Copy() instead System.IO.File.Copy()

如果您不想或不能使用 AlphaFS,则必须调用 Win32 API

If you don't want or cannot use AlphaFS you'll have to pinvoke the Win32 API

这篇关于PathTooLongException C# 4.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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