Skip to content

Instantly share code, notes, and snippets.

@ortonomy
Created November 17, 2016 02:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ortonomy/c1259f7eba2c50d8bf981c528d976d39 to your computer and use it in GitHub Desktop.
Save ortonomy/c1259f7eba2c50d8bf981c528d976d39 to your computer and use it in GitHub Desktop.
using System;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;
public class DirectoryListing:Page
{
protected void WriteTitle()
{
Response.Write("Listing contents of directory");
}
protected void WriteFiles()
{
DirectoryInfo dir;
FileInfo[] files;
dir = new DirectoryInfo(Server.MapPath("."));
files = dir.GetFiles();
foreach (FileInfo f in files) {
if ( f.Name.ToString() != "index.aspx" && f.Name.ToString() != "web.config" && f.Name.ToString() != "DirectoryListing.cs") {
Response.Write("<a href=\"" + f.Name.ToString() + "\">");
Response.Write(f.Name.ToString() + "</a><br />");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment