Geeks With Blogs
HanSolo code monkey
Here is a code snippet for writing to a file asynchronously:

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(EndWriteCallback), new State());

private void EndWriteCallback(IAsyncResult result)
Posted on Thursday, October 15, 2009 1:48 PM | Back to top

Comments on this post: Writing to a file asynchronously

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © HanSolo | Powered by: