Introduction:
In my previous article I have explained about how
to get subdirectories or sub folders from a directory in C#.Net or ASP.Net.
In this article I am going to explain about how to get all files in a directory
using C#.Net and Asp.Net.
Explanation:
GetFiles method in the System.IO.Directory class is used for getting all the files from a
directory. Below sample code gets all files from a specified folder and prints
It in the web page.
protected void Page_Load(object sender, EventArgs
e)
{
string
rootFolder = @"E:\FileFolder\";
string[]
files = Directory.GetFiles(rootFolder);
foreach (string file in files)
Response.Write(file+"<br/>");
}
Comments
Post a Comment