PathTooLongException C#4.5 [英] PathTooLongException C# 4.5

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

问题描述

我无法复制一些文件夹260+字符(例如:F:\NNNNNNNNNNNNNNNNNNNNNNNNNNN\ROOT\ $ RECYCLE.BIN\S-1-5-21-3299053755-4209892151-505108915- 1000\ $ RMSL3U8\NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN\NNNNNNNNN\P1DNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN.exe.manifest)到其他一些其他地方与标准的DrectoryInfo.Create();添加\?\或\?\UNC\(如\\?\UNC\)只是抛出另一个ArgumentException。
我做错了什么?没有使用Directory.SetCurrentDirectory()还有什么我可以做的?

解决方案

是的,使用标准的API会给你这样的限制(255个chars IIRC)。



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



您可能会使用这个库,就像您使用的是System.IO,例如:AlphaFS.Win32.Filesystem。 File.Copy()而不是System.IO。文件.Copy()



如果你不想或不能使用AlphaFS,你必须固定Win32 API


I having trouble of copying some folder 260+ chars (for example: F:\NNNNNNNNNNNNNNNN\NNNNNNNNNNN\ROOT\$RECYCLE.BIN\S-1-5-21-3299053755-4209892151-505108915-1000\$RMSL3U8\NNNNNNNNN NNNNNNNN\NNNNNNNNNNN\NNNNNNNNNN\NNNNNNNNNN\publish\Application Files\TNNNNNNNNNNNN_1_0_0_0\NNNNNNNNNNNN.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() ?

解决方案

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

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

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()

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

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

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