In our real life applications it is required to read, write,
or manipulate files and directories. The .NET Framework provides a set of
classes in the System.IO namespace to allow synchronous and asynchronous
reading from and writing to data streams and files. Before working with files
and directories it is essential to make sure that security permissions are set
properly on folders and files where you want to write. The .NET Framework runs
all ASP.NET processes under the local ASPNET account. This account needs to
have write permissions to all the folders and files that are being used to
write data. To set permissions of that folder the steps to be followed are: right-click
the folder, go to properties, security tab, and then make sure the local ASPNET
account has read and write permissions on that folder. If they do not, add
local ASPNET account to the list and give it read and write permissions and
then click ok. In this article I have tried to discuss most of the methods
available in the Directory, DirectoryInfo, File and FileInfo classes. The
sample code snippets in this article have been written in C#.