在 NTFS 中搜索文件 [英] Searching files in NTFS

查看:36
本文介绍了在 NTFS 中搜索文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个相当大的磁盘阵列,上面有大约 2-3 百万个 XML 文件.磁盘格式化为 NTFS,我们想使用通配符搜索文件系统.所以像 * SomePartOfTheFilename * 这样的东西将是一个典型的搜索查询.

We have a fairly large disk array with roughly 2-3 million XML files on it. The disk is formatted with NTFS and we would like to search the filesystem using wildcards. So something like * SomePartOfTheFilename * would be a typical search query.

我们正在使用 .Net 并且发现使用 DirectoryInfo 似乎很慢.

We are using .Net and are finding that using DirectoryInfo appears to be slow.

DirectoryInfo directoryInfo = new DirectoryInfo(directory);

List<FileInfo> fileInfos = directoryInfo.GetFiles(searchString, SearchOption.AllDirectories).ToList();

使用循环和递归也很慢.

Using Loops and recursion is also very slow.

是否可以使用较低级别的 API 调用来直接搜索 NTFS 索引?

Is there a lower level API call we can use to directly search the NTFS index?

从命令行使用 dir * SomePartOfTheFilename */s 几乎是即时的.有什么可以利用的吗?

Using dir * SomePartOfTheFilename * /s from the command line is almost instant. Is there something there that can be leveraged?

推荐答案

您可以直接使用 MFT(参见:NTFS 维基).那是数据表,其中包含有关文件的所有信息.你可以看到 MFT 的结构,例如 here此处.Windows API 最终出现在同一个表中,因此您也可以尝试加快搜索速度,以确保在搜索之前将其分页到内存中(简单读取例如 c:\$Mft 就足够了).

You may use MFT directly (See: NTFS Wiki). That is data table where all information about files is located. You can see the structure of MFT for example here or here. The Windows API ends up in the same table so you can alternatively try to speed the searches up to guarantee that it will be paged in memory before search (simple read of e.g. c:\$Mft is enough).

这篇关于在 NTFS 中搜索文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆