如何快速查询文件系统?
我正在尝试查询远程计算机上的文件系统,以便获取特定目录中的文件名列表。
到目前为止,我在 .NET 中使用 DirectoryInfo 类。 类似这样:
DirectoryInfo dir = new DirectoryInfo("c:\dir");
FileInfo[] files = dir.GetFiles("*.*");
但是这个查询平均需要 20/30 秒才能回答。 有时持续50秒。 那就太多了。 我想优化它。 经过一番谷歌搜索后,我发现这可以通过 WMI 来完成。 但我没有取得任何成功。 我收到诸如“RPC 服务器不可用”之类的错误,并且我无权更改该计算机中的权限或服务。
还有人有其他想法吗?
I'm trying to query the filesystem on a remote machine in order to get a list of file names in a specific directory.
Until now, I'm using the DirectoryInfo class in .NET. Something like this:
DirectoryInfo dir = new DirectoryInfo("c:\dir");
FileInfo[] files = dir.GetFiles("*.*");
But this query answers in an average of 20/30 seconds. Sometimes is lasts 50 seconds. That's to much. I want to optimize it. After some googling I've found that this could be done with WMI. But I'm not getting any success. I'm getting errors like "RPC server is unavailable" and I don't have access to change permissions or services in that machine.
Does anyone have any other idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不会获得更快的网络性能。 您正在应对网络延迟以及影响远程计算机性能的任何情况(例如磁盘 io 或高 CPU 使用率)。
You won't get any faster performance going across the network. You're combatting network latency, as well as anything that's happening to affect the performance on the remote machine (eg., disk io or high CPU usage).
远程计算机上运行的 WCF 服务怎么样? 这可以接受请求,然后返回带有文件夹和文件的对象图的批量数据传输对象。
我知道这可能不适合您的架构,但如果您可以控制这两个环境,这可能是一种前进的方式?
What about a WCF service running on the remote machine? That could take a request, then return a bulk data transfer object with an object graph of the folders and files.
I appreciate this might not fit with your architecture, but if you have control over both environments it might be a way forward?