Get file names from a directory
Posted by putxi on April 18, 2007
This code is very usefull when you wanna print or show all the files in a directory. You can get all the sames like this esasy way in c sharp.
DirectoryInfo diretorio = new DirectoryInfo(Server.MapPath(“Arxius/”));
lb_Arquivos.DataSource = diretorio.GetFiles();
lb_Arquivos.DataBind();
}
void Page_Load(object s, EventArgs e)
{
DirectoryInfo di = new DirectoryInfo(“c:/inetpub/wwwroot/demos”);
FileInfo[] rgFiles = di.GetFiles(“*.aspx”);
foreach(FileInfo fi in rgFiles)
{
Response.Write(“<br><a href=” + fi.Name + “>” + fi.Name + “</a>”);
}
}
Remember: Catalonia is not spain!









Roel said
I saw on the worldmap that Catalonia actually is Spain.
Cars said
Hi there…
Gotta love yahoo, very neat website. Thanks alot….