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
-
Export Datagrid to Excel with same formatting
by BarbaMariolino (1 replies)
-
how to design a template platform which can be used to create many different pages?
by polytheme (1 replies)
-
sending sms from pc
by sriraj20074 (0 replies)
-
Capture Video
by ess-image (23 replies)
-
DataGrid - How to display the content of a hidden TemplateField on mouseover
by DonCarnage (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?
Events coming up
-
Jul
7
DTC 70-528 Session 7: Chapter 12
Greenwood Village, United States
Due to lack of interest of the 5th Monday meetup, we will continue as originally scheduled. The topic of the night will be "Chapter 12 - Creating ASP.NET Mobile Web Applications", taught by RJ Hatch. It is a fairly small chapter, so we can discuss other topics as well. Pizza and beverages will be provided on a donation basis.
This thread is for discussions of How to get an array of all files in a directory.