Ever thought of creating files on the fly (say by typing contents  in a textbox) and saving them to the document library? refer to my previous post https://techolyvia.wordpress.com/2009/01/13/how-to-create-files-dynamically-and-save-that-in-document-library/ which talks about this.

Now, if we want to edit the uploaded data, we need to read the content from the document library and show the content in the textbox. So, how do we do that? See the code below:

SPSite ospSite = SPContext.Current.Site;
SPWeb ospWeb = ospSite.OpenWeb();
/*docPath returns the url of the file as sharepoint url/document library/filename*/
string docPath = Request.QueryString[“Path”];
SPFile tempFile = ospWeb.GetFile(docPath);
/*OpenBinaryStream() opens the file as a stream*/
StreamReader reader = new StreamReader(tempFile.OpenBinaryStream());
/*txtUpload is the textbox control where we insert the value of the text file*/
txtUploadText.Text = reader.ReadToEnd();

So, we use StreamReader to read the content of the text file in document library and display the content in a Multiline Textbox, so that the user can  edit the content of the textfile.

For details refer to http://www.dotnetspider.com/forum/189095-Read-file-content-from-document-library-write-textbox.aspx