.


:




:

































 

 

 

 


, .




// .

Using System; using System.10;

class WriteToFile {

static void Main(string[] args) {

FileStream fout = null;

try {

// .

fout = new FileStream("test.txt", FileMode.CreateNew);

// , for(char = ''; <= ' Z '; C++) fout.WriteByte((byte) );

} catch(IOException exc) {

Console.WriteLine (." -: \n" + exc.Message);

} finally {

if(fout!= null) fout.Close();

}

}

}

test. txt FileMode. CreateNew. , . ( IOException.)

. test. txt .

ABCDEFGHIJKLMNOPQRSTUVWXYZ

 

FileStream

- FileS tream , , , , . , , . .

/* .

, . , FIR'ST.DAT SECOND.DAT :

CopyFile FIRST.DAT SECOND.DAT

*/

Using System; using System.10;

class CopyFile {

static void Main(string[] args) { int i;

FileStream fin = null;

FileStream fout = null;

if(args.Length!= 2) {

Console.WriteLine(": CopyFile "); return;

}

try { 1

// .

fin = new FileStream(args[0], FileMode.Open); fout = new FileStream(args[1], FileMode.Create);

// , do {

i = fin.ReadByte();

if(i!= -1) fout.WriteByte((byte)i);

} while (i!= -1);

} catch(IOException exc) {

Console.WriteLine(" -:\n" + exc.Message);

} finally {

if(fin!= null) fin.Close (); if(fout!= null) fout.Close ();

>

-

, . , . , , . , - FileStream StreamReader StreamWriter. .

, , , . StreamReader StreamWriter .

StreamWriter tW rite , StreamReader TextReader. , StreamReader StreamWriter , .

StreamWriter

Stream, FileStream, StreamWriter. StreamWriter . :

StreamWriter(Stream )

. ArgumentException, , ArgumentNullException, . StreamWriter .

, test. txt. , "". FileStream, StreamWriter.

// ,

// StreamWriter.





:


: 2016-12-03; !; : 441 |


:

:

- , , .
==> ...

831 - | 698 -


© 2015-2024 lektsii.org - -

: 0.01 .