• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

Reading Text Blob line by line

How do i read a text blob , line by line like i am reading it from a text file ?

while ((line = file.ReadLine()) != "end")
                    {
                      // do stuff
}
0
byte1
Asked:
byte1
  • 2
1 Solution
 
Easwaran ParamasivamCommented:

int counter = 0;
string line;

// Read the file and display it line by line.
System.IO.StreamReader file =  new System.IO.StreamReader(@"c:\test.txt");

while((line = file.ReadLine()) != null)
{
   Console.WriteLine (line);
   counter++;
}

file.Close();

// Suspend the screen.
Console.ReadLine();

Open in new window

0
 
JustAndreiCommented:
If you know for sure your BLOB is textual data, you just need to cast it to string and wrap into System.IO.StringReader. StringReader and StreamReader have the same base abstract class TextReader, so you can easily work with the same methods.
0
 
JustAndreiCommented:
In the same manner binary BLOB data can be wrapped into MemoryStream. Then you can read it as any other stream.
0
 
byte1Author Commented:
Thanks, that really worked.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now