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
-
Stock Exchange Rate
by devart_jamesyang (3 replies)
-
Interested to learn
by Milind_Kansagara (2 replies)
-
Windows XP,Office XP for sale 35 pounds.
by recoversvr (0 replies)
-
Navigation Buttons
by awd (0 replies)
-
question about developerfusion.com
by James Crowley (1 replies)
Related jobs
-
Microsoft .Net Architect
in AMSTERDAM (€50K-€90K per annum) -
Microsoft Dynamics CRM Technical Consultant
in Netherlands (€50K-€90K per annum)
Events coming up
-
Oct
14
What’s New in Visual Studio 2008 Service Pack 1?
Birmingham, United Kingdom
“Service Pack? We’re calling it a Service Pack? Are you kidding??!?!” Visual Studio 2008 Service Pack 1 will release later in 2008 alongside .NET Framework V3.5 Service Pack 1 and, together, they represent a significant upgrade to Visual Studio 2008. There are enhancements across many areas of the .NET Framework such as data access, windows application development and web development and there are also corresponding changes in the development environment to support the new framework features.
Thats exactly what I needed. Nice one