class ShowFile {
static void Main(string[] args) { int i;
FileStream fin = null;
if (args.Length!= 1)' {
Console.WriteLine(": ShowFile File"); return;
}
try {
fin = new FileStream(args[0], FileMode.Open);
// , do {
i = fin.ReadByte();
if(i!= -1) Console.Write((char) i);
} while (i!= -1);
} catch(IOException exc) {
Console.WriteLine(" -:\n" + exc.Message);
} finally {
if(fin!= null) fin.Close();
}
}
}
, fin FileStream . FileStream, fin , . , Close () finally , fin . lose () fin, . -, . , , , , , , . , , , , , try, .
, , . , , . .
WriteByte(). .
void WriteByte(byte value)
, value. , NotSupportedException. , ObjectDisposedException.
Write . .
void Write(byte[] array, int offset, int count)
Write () count array, array[offset]. , . , IOException. , NotSupportedException. , .
, , , . , , . . , 128 . , ..
|
|
, Flush.
Void Flush()
IOException. , ObjectDisposedException.
Close (). , , , . Flush () .