View Single Post
  #1 (permalink)  
Old 07-19-2008, 08:57 AM
techexpert techexpert is offline
Registered User
 
Join Date: Jul 2008
Posts: 1
Code for How to read file content in .Net

This is the code how to read file content through .Net.



Code:
public String ReadFileContent(FileSettings file)

{ 

FileStream fs = new FileStream(file.FilePath,FileMode.Open,FileAccess.Read);

StringBuilder output = new StringBuilder();

StreamReader r = new StreamReader(fs);

r.BaseStream.Seek(0,SeekOrigin.Begin);

String fContent="";

while (r.Peek() > -1)

{

fContent = fContent + r.ReadLine();

}

r.Close();

return fContent;

}


--------------------------------------------------------------------------------

Last edited by curtiss; 07-19-2008 at 10:20 AM.
Reply With Quote