In C # using use - to write to the file, for example FileStream

Scenes

In contrast FileStream CS and methods of use:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100396022

Public concern number
overbearing program ape
acquisition-related programming e-books, tutorials and push for free download.

achieve

Will create a file stream object using the process of writing in, it will automatically help us to release the resources occupied by the stream.

New command line program:

// use FileStream to write 
a using (FileStream fsWrite = new new FileStream ( @ " C: \ the Users \ Administrator \ Desktop \ badao.txt " , FileMode.OpenOrCreate, FileAccess.Write)) 
    { 
      String str = " public concern number: handed procedure ape, ape handed procedure, handed procedure ape, ape procedures handed " ;
       byte [] = Buffer Encoding.Default.GetBytes (STR); 
      fsWrite.Write (Buffer, 0 , buffer.Length); 
     } 
    Console .WriteLine ( " successfully written " ); 
    Console.ReadKey ();

 

running result

 

Guess you like

Origin www.cnblogs.com/badaoliumangqizhi/p/11449378.html