Created
November 17, 2016 02:20
-
-
Save ortonomy/c1259f7eba2c50d8bf981c528d976d39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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