简体   繁体   English

.NET中用于将字符串搜索到最大1GB的大文件/文件夹中的最佳和最快的技术是什么?

[英]What is the best and fastest technique in .Net for searchin a string into a large file/folder upto 1GB?

I want to search a string (in every 5 to 10 mints) in text files or folder which might be of 500MB space. 我想在可能有500MB空间的文本文件或文件夹中搜索字符串(每5至10分钟)。 I want to know which technique would be fruitful to implement this searching. 我想知道哪种技术对实现这种搜索会有帮助。 Please let me know if anything was unclear. 请让我知道是否有任何不清楚的地方。 I am using csharp.net. 我正在使用csharp.net。

Thanx & Regards 谢谢与问候

The first thing to do is to write something that achieves your desired result. 首先要做的是写一些可以达到预期效果的东西。

Then use a profiler to determine what is taking the longest time! 然后,使用探查器确定耗时最长的时间!

Once you've found the bit that takes the longest time, see if there's any way to improve that. 一旦找到花费时间最长的位,请查看是否有任何方法可以改善它。

Now, from your question, I can probably determine that the bit that's going to take the longest will be the transfer of the data from the hard drive to RAM. 现在,从您的问题中,我可能可以确定花费最长时间的位将是数据从硬盘驱动器到RAM的传输。 If the file contains different data each time you search it then this will define the upper limit of how fast you can do the search. 如果文件每次搜索都包含不同的数据,则这将定义搜索速度的上限。 If the file does not change then there's a few possibilities to improve the upper limit. 如果文件没有更改,则有几种方法可以提高上限。

But first, find out what's taking the time. 但是首先,找出花费时间。

您可以使用Windows桌面搜索API(请参阅此处 )执行搜索。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM