Learning CSHARP by Example
Read a file with a single call to sReader.ReadToEnd() using streams
public static string getFileAsString(string fileName) { StreamReader sReader = null; string contents = null; try { FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); sReader = new StreamReader(fileStream); contents = sReader.ReadToEnd(); } finally { if(sReader != null) { sReader.Close(); } } return contents; }
+ نوشته شده در چهارشنبه چهارم اسفند ۱۳۸۹ ساعت 20:13 توسط علی احمدی
|