how to read the data using streamreader

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gandinarender
    New Member
    • Oct 2006
    • 3

    how to read the data using streamreader

    hello every one,i have used a stream reader to read a file, but after the compilation i am not able to get the text in the file as it is.for example i am retrieving a .doc file(ex:resume) and when i retrieve the same file using stream reader, the text is not completely displayed.so can anyone send me the code to retrieve a file...

    here is my code:


    TextBox1.Visibl e = True
    Dim fs As New FileStream(Serv er.MapPath("fil es\gandi.doc"), FileMode.Open, FileAccess.Read )
    Dim s As New StreamReader(fs )
    s.BaseStream.Se ek(0, SeekOrigin.Begi n)
    While s.Peek() > -1
    TextBox2.Text &= s.ReadLine()

    End While
    s.Close()
  • rakeyshkg
    New Member
    • Oct 2006
    • 2

    #2
    Originally posted by gandinarender
    hello every one,i have used a stream reader to read a file, but after the compilation i am not able to get the text in the file as it is.for example i am retrieving a .doc file(ex:resume) and when i retrieve the same file using stream reader, the text is not completely displayed.so can anyone send me the code to retrieve a file...

    here is my code:


    TextBox1.Visibl e = True
    Dim fs As New FileStream(Serv er.MapPath("fil es\gandi.doc"), FileMode.Open, FileAccess.Read )
    Dim s As New StreamReader(fs )
    s.BaseStream.Se ek(0, SeekOrigin.Begi n)
    While s.Peek() > -1
    TextBox2.Text &= s.ReadLine()

    End While
    s.Close()






    hi,

    reading file which is in memory stream using string reader

    StringReader str;
    str = new StringReader(fi lename stored in memorystream);
    XmlTextReader reader = null;
    reader = new XmlTextReader(s tr);
    string attribute = null;
    string element = null;
    string value;

    while (reader.Read())
    {
    switch (reader.NodeTyp e)
    {
    case XmlNodeType.Ele ment:
    if (reader.Name == "<tags>")
    {
    reader.Read();
    element = reader.Name;
    while (reader.MoveToN extAttribute())
    attribute = reader.Value;
    }
    break;
    }
    }
    value = attribute + element;
    return value;

    Comment

    Working...