Library code snippets
How to get an array of all files in a directory
By Edward Tanguay, published on 07 Jul 2003
This simple code will give you an array containing all files in a directory.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
void Page_Load(object sender, EventArgs e) {
FileInfo fi = new FileInfo(Server.MapPath(""));
DirectoryInfo di = fi.Directory;
FileSystemInfo[] fsi = di.GetFiles();
Response.Write("The directory contains the following files and directories:" + di.FullName + "<hr>");
foreach (FileSystemInfo info in fsi)
Response.Write(info.Name + "<br>");
}
</script>
Related articles
Related discussion
-
sharepoint calendar web part with events from sql table
by tukubapi2207 (1 replies)
-
Using FedEx Web Service to Calculcate Shipping Cost
by bhora123 (4 replies)
-
Very Urgent regarding deleting the images from a folder
by rameshbandi (2 replies)
-
Dynamically Generating PDFs in .NET
by nike12 (10 replies)
-
New style of Javascript used in extenders.
by mittalpa (0 replies)
Related podcasts
-
StackOverflow uses ASP.NET MVC - Jeff Atwood and his technical team
Scott chats with Jeff Atwood of CodingHorror.com and most recently, StackOverflow.com. Jeff and Joel Spolsky and their technical team have created a new class of application using ASP.NET MVC. What works, what doesn't, and how did it all go down?
This thread is for discussions of How to get an array of all files in a directory.