THE PUTXI PROJECT

Catalonia is Not Spain

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!

Advertisements

2 Responses to “Get file names from a directory”

  1. Roel said

    I saw on the worldmap that Catalonia actually is Spain.

  2. Cars said

    Hi there…

    Gotta love yahoo, very neat website. Thanks alot….

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: