FileMode.Open
using System;
using System.IO;
class MainClass {
public static void Main(string[] args) {
int i;
FileStream fin;
FileStream fout;
try {
fin = new FileStream("inputFile.txt", FileMode.Open);
} catch(FileNotFoundException exc) {
Console.WriteLine(exc.Message + "\nInput File Not Found");
return;
}
try {
fout = new FileStream("outputFile.txt", FileMode.Create);
} catch(IOException exc) {
Console.WriteLine(exc.Message + "\nError Opening Output File");
return;
}
try {
do {
i = fin.ReadByte();
if(i != -1)
fout.WriteByte((byte)i);
} while(i != -1);
} catch(IOException exc) {
Console.WriteLine(exc.Message + "File Error");
}
fin.Close();
fout.Close();
}
}
Related examples in the same category