在目录中搜索大量文件?
我正在使用 MSVE,并且我有自己的图块,并在顶部的图层中显示。 问题是,它们有很多,并且位于网络服务器上。 在某些目录中,大约有 30,000 多个文件。 最初我调用了 Directory.GetFiles,但是当我开始在伪真实环境中进行测试时,它就超时了。
以编程方式列出和迭代这么多文件的最佳方法是什么?
编辑:我的同事建议使用 MS 索引服务。 有人尝试过这种方法吗?它(如何)有效?
I'm using MSVE, and I have my own tiles I'm displaying in layers on top. Problem is, there's a ton of them, and they're on a network server. In certain directories, there are something on the order of 30,000+ files. Initially I called Directory.GetFiles, but once I started testing in a pseudo-real environment, it timed out.
What's the best way to programatically list, and iterate through, this many files?
Edit: My coworker suggested using the MS indexing service. Has anyone tried this approach, and (how) has it worked?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我过去曾在一个带有电话录音的 SAN 系统上工作过,该系统在单个文件夹中的文件数量方面存在问题 - 该系统在接近 5,000 个文件时变得无法使用(在 Windows 2000 Advanced Server 上,具有 C#.Net 1.1 中的应用程序) -我们提出的唯一明智的解决方案是更改文件夹结构,以便有更合理的文件数量。 有趣的是,Explorer 也会超时!
我们提出的约定是一种将结构分解为年、月和日的结构 - 但这将取决于您的系统以及您是否可以控制目录结构......
I've worked on a SAN system in the past with telephony audio recordings which had issues with numbers of files in a single folder - that system became unusable somewhere near 5,000 (on Windows 2000 Advanced Server with an application in C#.Net 1.1)- the only sensible solution that we came up with was to change the folder structure so that there were a more reasonable number of files. Interestingly Explorer would also time out!
The convention we came up with was a structure that broke the structure up in years, months and days - but that will depend upon your system and whether you can control the directory structure...
肯定要把他们分开。 也就是说,请尽可能远离索引服务。
Definitely split them up. That said, stay as far away from the Indexing Service as you can.
没有任何。 .NET 依赖于底层的 Windows API 调用,而这些 API 调用本身确实非常讨厌大量的文件。
正如罗尼所说:把他们分开。
None. .NET relies on underlying Windows API calls that really, really hate that amount of files themselves.
As Ronnie says: split them up.
可以用DOS吗?
You could use DOS?
您还可以查看自己对文件建立索引,或者获取第三方应用程序,例如 google 桌面或 copernic 来执行此操作,然后与其索引进行交互。 我知道 copernic 有一个 API,您可以使用它来搜索索引中的任何文件,并且它还支持映射网络驱动器。
You could also look at either indexing the files yourself, or getting a third part app like google desktop or copernic to do it and then interface with their index. I know copernic has an API that you can use to search for any file in their index and it also supports mapping network drives.