O'Reilly logo

.NET Framework 4.5 Expert Programming Cookbook by A.P. Rajshekhar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using asynchronous file I/O for directory-to-directory copy

Asynchronous file I/O has been a feature of .NET from Version 1.1 onwards. However, the loops that the developer had to run to get it working were many. In Version 4.5, .NET introduced a new API that would make using asynchronous file operation easy. At the core of the API, we have two operators—async and await. This recipe will focus on using these operators to implement an asynchronous directory-to-directory copy utility.

How to do it...

The following steps will help you perform directory-to-directory copy using asynchronous file I/O:

  1. Launch Visual Studio .NET 2012. Create a project of type Class Library and name it CookBook.Recipes.Core.AsyncFileIO.
  2. Rename Class1.cs to Utils.cs.
  3. Open

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required