• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 322
  • 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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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