如何在大型文本文件中搜索字符串而不在C#中逐行查找? [英] How do you search a large text file for a string without going line by line in C#?

查看:46
本文介绍了如何在大型文本文件中搜索字符串而不在C#中逐行查找?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大的文本文件,需要搜索特定的字符串。

I have a large text file that I need to search for a specific string. Is there a fast way to do this without reading line by line?

这种方法非常慢,因为文件大小很大(大于100 MB)。

/ p>

This method is extremely slow because of the size of the files (more than 100 MB).

推荐答案

鉴于文件的大小,您真的要事先将它们全部读取到内存中吗?逐行可能是这里最好的方法。

Given the size of the files would you really want to read them entirely into memory beforehand? Line by line is likely to be the best approach here.

这篇关于如何在大型文本文件中搜索字符串而不在C#中逐行查找?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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