how to read the txt file from the database(line by line)

Posted by Ranjana on Stack Overflow See other posts from Stack Overflow or by Ranjana
Published on 2010-04-17T07:01:37Z Indexed on 2010/04/17 7:03 UTC
Read the original article Hit count: 310

Filed under:
|
|
|
|

i have stored the txt file to sql server database . i need to read the txt file line by line to get the content in it. my code :

DataTable dtDeleteFolderFile = new DataTable(); dtDeleteFolderFile = objutility.GetData("GetTxtFileonFileName", new object[] { ddlSelectFile.SelectedItem.Text }).Tables[0];

        foreach (DataRow dr in dtDeleteFolderFile.Rows)
        {
            name = dr["FileName"].ToString();
            records = Convert.ToInt32(dr["NoOfRecords"].ToString());
              bytes = (Byte[])dr["Data"];



        }

FileStream readfile = new FileStream(Server.MapPath("txtfiles/" + name), FileMode.Open);

      StreamReader streamreader = new StreamReader(readfile);

        string line = "";


        line = streamreader.ReadLine();

but here i have used the FileStream to read from the Particular path. but i have saved the txt file in byt format into my Database. how to read the txt file using the byte[] value to get the txt file content, instead of using the Path value.

© Stack Overflow or respective owner

Related posts about txt

Related posts about c#