views:

50

answers:

1

i have the following code ..i need to loop through end of the file as per the commented code shown below how i can do it ?

namespace BVParser
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            StreamReader sr = new StreamReader(@"D:\Jaison\JaisonWorking\EmailParse\Sample.BV.application.Mails\Sample.BV.application.Mails\ToTest\Test\SourceAscii.msg", Encoding.Unicode);
            string message = sr.ReadToEnd();
            StreamWriter sw = new StreamWriter(@"D:\Jaison\JaisonWorking\EmailParse\Sample.BV.application.Mails\Sample.BV.application.Mails\ToTest\Test\DestAsciiOutNewWOEncodingUnicode.txt");
            sw.Write(message);
            sw.Close();
            sr.Close();
            // StreamReader srseek = new StreamReader(@"D:\Jaison\JaisonWorking\EmailParse\Sample.BV.application.Mails\Sample.BV.application.Mails\ToTest\Test\DestAsciiOutNewWOEncodingUnicode6.txt");

            FileStream fs = new FileStream(@"D:\Jaison\JaisonWorking\EmailParse\Sample.BV.application.Mails\Sample.BV.application.Mails\ToTest\Test\DestAsciiOutNewWOEncodingUnicode6.txt", FileMode.Open, FileAccess.Read);
            StreamReader r = new StreamReader(fs);
            int index = message.IndexOf("prod-");
            //Label2.Text = index.ToString();
            Cluster.Text = message.Substring(index + 5, 2);
            int indexend = message.IndexOf(" ", index);
            int indexdiff = indexend - index;
            Servers.Text = message.Substring(index, indexdiff);

           // Loops should start here.. checking indexat("EOF")  

          While ()
          {
             int exindex = message.IndexOf("Exception:");
                int checkspace = exindex;
                checkspace--;
                if (checkspace == ' ')
                {
                    exindex = message.IndexOf("Exception:", exindex);
                }

                int trav = exindex;
                while (message[trav] != '.') // || message[trav] != ' '
                {
                    trav--;
                }

                int expdiff = exindex - trav + 9;
                Exceptions.Text = message.Substring(trav, expdiff);
                int lastdescindex = message.IndexOf('\n', exindex);
                int firstdescindex = exindex + 10;
                int diffdesc = lastdescindex - firstdescindex;
                Desc.Text = message.Substring(firstdescindex, diffdesc);

            // } Loop should end here.


            fs.Close();

        }
    }
}
A: 

This is an example of something I've done...

    StreamReader reader = File.OpenText(filename);
    string line = null
    while ((line = reader.ReadLine()) != null)
    {
    // ... your stuff here
    }
    reader.Close();
    reader.Dispose();
Aaron
Cannot implicitly convert type 'int' to 'bool'
but my context is different here..i am using a file stream to parse strings ... i want iterate the parsing processs again where i mentioned the loop ..untill the end of file reached ..see the comments above
Removed the top part of my answer...I was thinking of a different type of reader. The remaining part should be what you're looking for.
Aaron