October 2009 Entries

Writing to a file asynchronously

Here is a code snippet for writing to a file asynchronously: private void writeFileAsync(string text) { System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); byte[] buffer = encoding.GetBytes(text); using (FileStream fs = new FileStream("temp.txt", FileMode.Append, FileAccess.Write, FileShare.ReadWrite, buffer.Length, FileOptions.Asynchronous)) { IAsyncResult asyncResult = fs.BeginWrite(buffer, 0, buffer.Length, new AsyncCallback(EndWriteCallb... new State()); } } private void EndWriteCallback(IAsyncResult...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

«October»
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567