Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 423

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 423

Warning: Cannot modify header information - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 426

Warning: Cannot modify header information - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/templates/ja_purity/ja_templatetools.php on line 49
Open and read a text file in C# - The Scripts Library Community

Free Programming Tutorials & Source Code

 
  • Increase font size
  • Default font size
  • Decrease font size
Home C# Open and read a text file in C#

Open and read a text file in C#

E-mail
(0 votes, average: 0 out of 5)
A code spinets of how to open and read a text file using c#.
 
// Define a StreamReader
private System.IO.StreamReader strReader;
private int FileChar;
private void btnOpen_Click(object sender, System.EventArgs e)
{
// Open the file 
strReader = File.OpenText("c:/txtFileName.txt");
// Loop trough each character to the end of the file
while ((FileChar = strReader.Read()) != -1)
{
// Show the current char
//MessageBox.Show(Convert.ToChar(FileChar).ToString());
}
// Close the reader
strReader.Close();
}