如何克服 PathTooLongException?
因此,我正在编写一个程序,该程序将扫描计算机上的重复文件,因为我见过的程序非常慢,并且/或占用内存,但是当我尝试时,我遇到了 PathTooLongException 。到整个驱动器。阅读 C# 代码中的 PathTooLongException 后,我对以下两个问题感到好奇。
如果每次更改级别时都切换当前目录,会影响我的性能吗?
有没有更好的方法来获取所有文件的目录结构(也许通过调用诸如tree.exe之类的东西然后解析它)?
So I am writing a program that will scan for duplicate files on a computer as the programs that I've seen are really slow, and/or memory hogs, but I was running into a PathTooLongException
when I tried to the whole drive. After reading PathTooLongException in C# code I became curious about the following two questions.
Would it hurt my performance if I were to switch my current directory every time I changed levels?
Is there a better way to get the directory structure of all the files (perhaps by calling something like tree.exe and then parsing that)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看看这个图书馆!
.NET 基类库:长路径
See this Library!
.NET Base Class Libraries : Long Path
或者自己做,
我还没有验证这个代码,显然并不是所有的类型都被定义,但它应该为我们指明正确的方向。
or do it yourself,
I haven't verified this code and obviously not all the types are defined but it should point us in the right direction.
纯 C#,需要优化,但无需使用外部库或 p/invoking 即可为人们提供领先优势。
Pure C#, needs optimization but will give people a headstart without using an external library or p/invoking..