PathTooLongException C#4.5 [英] PathTooLongException C# 4.5
问题描述
我做错了什么?没有使用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屋!