DirectoryInfo、FileInfo 和很长的路径

发布于 2024-08-04 08:17:08 字数 531 浏览 4 评论 0原文

我尝试使用具有很长路径的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

屌丝范 2024-08-11 08:17:08

在此位置再次提供该库。

这是一个针对 .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未处理。

信息:

指定的路径、文件名或两者都太长。完全
合格的文件名必须少于 260 个字符,并且
目录名称必须少于 248 个字符。

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 the
System.IO it does have most objects and functions available.

Delimon.Win32.IO replaces basic file functions of System.IO
with long path names support for characters up to 32,767 Characters
So bye bye MAX_PATH problem

Did you ever run into this problem?

System.IO.PathTooLongExceptionwas unhandled.

Message:

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.

鸵鸟症 2024-08-11 08:17:08

查看 .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.

著墨染雨君画夕 2024-08-11 08:17:08

Delimon.Win32.IO 库 (V4.0) 也可用,它是针对 .NET Framework 4.0 编写的,可以在 x86 和 x86 上使用。 x64 系统。

The Delimon.Win32.I​O Library (V4.0) is also available, it is written against .NET Framework 4.0 and can be used either on x86 & x64 systems.

杯别 2024-08-11 08:17:08

我过去解决这个问题的方法是使用 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

摘星┃星的人 2024-08-11 08:17:08

从 .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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文