如何在“电子邮件:”之后阅读文本通过流阅读器无需循环... [英] How to read a text after "Email:" via stream reader without looping ...

查看:76
本文介绍了如何在“电子邮件:”之后阅读文本通过流阅读器无需循环...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在电子邮件:之后通过流阅读器阅读文本而不进行循环...有没有简单的方法来快速获取它,因为我一次检查大量文件....

How to read a text after "Email:" via stream reader without looping ...Is there any easy method to get it fast as i am checking large number of files at a time....

StreamReader reader = new StreamReader(Target1);
            string line = string.Empty;

            var matches1 = Regex.Match('Email', ('^.*')).Groups[1].Value;
            while ((line = reader.ReadToEnd().ToLower()) != null)
            {
                if (line.Contains('email'))
                {
                    string[] crefids3 = line.Split(':');
                    for (int mj = 0; mj < crefids3.Length; mj++)
                    {
                        randomName = crefids3[1].ToString();
                    }
                }
            }
            reader.Close();

推荐答案

取决于你的意思是大。但如果你真的意味着非常大的数量,那么一般来说答案是否定的。您可能能够增加缓冲区大小,但这取决于实际的流。



小心你可能会发现,如果你先解析它然后处理它你可能会得到它更好的性能(现在它看起来像你正在处理它一旦找到。)



你可能还会检查你需要加快它 - 特别是这是一个业务要求或只是你认为理想的东西?
Depends on what you mean by "large". But if you really mean very large amounts then in general the answer is no. You might be able to increase the buffer size but that depends on the actual stream.

With care you might find that if you parse it first then process it you might get better performance (right now it looks like you are processing it once found.)

You might also examine your need to make it faster - specifically is this a business requirement or just something you think is ideal?


这篇关于如何在“电子邮件:”之后阅读文本通过流阅读器无需循环...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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