This tutorial will show you how to delete all files under a folder.

This tutorial will show you how to delete all files under a folder. First, import the namespace of System.IO. System.IO namespace containing the type allowing the read-write document and the data stream and provides the type that the basic document and the catalogue support.

The Button1_Click event is to perform the delete all file under a folder. We using GetDirectories to returns the subdirectories of the current directory, using GetFiles to returns all files of the current directory. And we can delete all file and directory with looping.

The Button1_Click event is to perform the delete all file under a folder. We using GetDirectories to returns the subdirectories of the current directory, using GetFiles to returns all files of the current directory. And we can delete all file and directory with looping.

The front end Default.aspx page looks something like this:

The flow for the code behind page is as follows.

Download Source Files