//Read a Text File///////////////////////////////////////////////////////////////////////////////////////////////////
using
System;
System.IO;
namespace
readwriteapp
{
class
Class1
[STAThread]
static
void
Main(
string
[] args)
String line;
try
//Pass the file path and file name to the StreamReader constructor
StreamReader sr =
new
StreamReader(
"C:\\Sample.txt"
);
//Read the first line of text
line = sr.ReadLine();
//Continue to read until you reach end of file
while
(line !=
null
)
//write the lie to console window
Console.WriteLine(line);
//Read the next line
}
//close the file
sr.Close();
Console.ReadLine();
catch
(Exception e)
Console.WriteLine(
"Exception: "
+ e.Message);
finally
"Executing finally block."
//Write a text file////////////////////////////////////////////////////////////////////////////////////////////////////
System.Text;
Int64 x;
//Open the File
StreamWriter sw =
StreamWriter(
"C:\\Test.txt"
,
true
, Encoding.ASCII);
//Writeout all the lines changing the coordinates.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// HOW CAN I DO THIS???
sw.Close();