List Boxes

 

StreamWriter (Writing a File)

StreamWriter also has a large number of overloaded constructors. Whenever you write to a file you must include the encoding format; otherwise , all sorts of bad things can happen. Shown below is a typical StreamWriter sequence:

 if(!File.Exists("SpareShort.dta") {   MessageBox.Show("Cannot find file 'SpareShort.dta'.");   return; } // Begin file opening and writing with 'StreamWriter'. // This next line provides a 'string' to write to file 'SpareShort.dta'. string strWNWBlock = "0444 04-44 22222.22 33333.33 444.44". ToString(); // Open existing file 'ShortSpare.dta' and write to it. // 'true' below means 'append to file'. 'false' means overwrite. StreamWriter jj = new StreamWriter("ShortSpare.dta", false, Encoding.ASCII, 47); jj.Write(strWNWBlock); jj.Close(); 
 


Unlocking Microsoft C# V 2.0 Programming Secrets
Unlocking Microsoft C# V 2.0 Programming Secrets (Wordware Applications Library)
ISBN: 1556220979
EAN: 2147483647
Year: 2005
Pages: 129

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net