DirectoryInfo、FileInfo 和很长的路径
我尝试使用具有很长路径的 DirectoryInfo、FileInfo。
- 我尝试使用 \\?\c:\long 路径(我在 fileInfo 和 DirectoryInfo 中使用非法字符)
- 我尝试使用 file://c:/long 路径(我不支持 uri)
我可以在路径或其他路径中使用 ~别的。
我读了这篇帖子,但我想使用另一种方式调用API。还有其他解决方案吗?
微软有一篇文章使用 \\?在文件路径 链接文本
问题是如何我可以使用很长的路径以及长度超过 256 个字符的路径的 DirectoryInfo 和 FileInfo
I try to work with DirectoryInfo, FileInfo with very long path.
- I try use \\?\c:\long path (i got illegal caracter with fileInfo and DirectoryInfo)
- I try use file://c:/long path (i got uri not supported)
Can i use ~ in a path or something else.
I read this post but i would like to use another way that call a API. Is it any other solutions ?
There is an article from microsoft for use \\? in file path link text
The question is how can i work with very long path, and DirectoryInfo, and FileInfo for path who are more longer that 256 char
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在此位置再次提供该库。
这是一个针对 .NET Framework 2.0 编写的 .NET 库,可用于
从 .NET 应用程序访问很长的文件夹和文件。
由于 .NET Framework 不支持长文件名:-(
我必须编写一个调用 WIN32 API 并包装这些 API 的库
类似 System.IO 的函数。虽然它不是完整的复制品
System.IO 它确实拥有大多数可用的对象和函数。
Delimon.Win32.IO
替换了System.IO
的基本文件功能长路径名支持最多 32,767 个字符
再见
MAX_PATH
问题您遇到过这个问题吗?
System.IO.PathTooLongException
未处理。信息:
The Library is available again on this location.
This is a .NET Library written against .NET Framework 2.0 and can be used to
access very long folder and files from a .NET application.
Since the .NET Framework does not support long filenames :-(
I had to write a library that calls the WIN32 API and wraps those
functions like
System.IO
. While it is not a complete replica of theSystem.IO
it does have most objects and functions available.Delimon.Win32.IO
replaces basic file functions ofSystem.IO
with long path names support for characters up to 32,767 Characters
So bye bye
MAX_PATH
problemDid you ever run into this problem?
System.IO.PathTooLongException
was unhandled.Message:
查看 .NET 中的长路径 博客文章 series,看起来像通过P/Invoke 是目前唯一的解决方案,除了重组目录以避免达到限制之外。
Looking at the Long Paths in .NET blog post series, it looks like going to the Win32 API through P/Invoke is the only solution at the moment, other than restructuring your directories so that you don't hit the limit.
Delimon.Win32.IO 库 (V4.0) 也可用,它是针对 .NET Framework 4.0 编写的,可以在 x86 和 x86 上使用。 x64 系统。
The Delimon.Win32.IO Library (V4.0) is also available, it is written against .NET Framework 4.0 and can be used either on x86 & x64 systems.
我过去解决这个问题的方法是使用 Delimon 的 Delimon.Win32.IO 库。看起来他的网站 http://www.delimon.be 目前已关闭。但我过去曾在一个项目中使用过它,而且效果非常好。我可以尝试在今晚晚些时候为您找到它,或者尝试通过谷歌在某个地方找到它的有效链接。干杯。这是另一个讨论这个问题的链接。
http://social.msdn .microsoft.com/Forums/en-US/netfxbcl/thread/2541a9b9-acd7-4338-89b1-dfc0408e41b5
A way I solved this issue in the past was using the library from Delimon called Delimon.Win32.IO. It looks like his site http://www.delimon.be is down at the moment. But I had used it on a project in the past and it worked like a champ. I can try to track it down for you later this evening or just try to find a valid link to it somewhere via google. Cheers. Here's another link talking discussing this issue.
http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/2541a9b9-acd7-4338-89b1-dfc0408e41b5
从 .NET 4.6.2 开始,可以通过更改本地计算机的组策略来解决此问题,从而允许 Win 10+ 和 Server 2016+ 上的长路径。
经测试并确认。
https://blogs.msdn.microsoft.com/jeremykuhne/2016/07/30/net-4-6-2-and-long-paths-on-windows-10/
As of .NET 4.6.2, this issue can be resolved with a change to the local machine's group policy, allowing for long paths on Win 10+ and Server 2016+.
Tested and confirmed.
https://blogs.msdn.microsoft.com/jeremykuhne/2016/07/30/net-4-6-2-and-long-paths-on-windows-10/