Created
December 29, 2013 19:45
-
-
Save SplittyDev/8174035 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
public byte[] GetRootFile () | |
{ | |
try | |
{ | |
StreamReader reader = new StreamReader (root + "index.html"); | |
string RootFile = reader.ReadToEnd (); | |
reader.Close (); | |
string ReplaceString = " Root<br/>"; | |
string[] Directories = Directory.GetDirectories (root, "*", SearchOption.AllDirectories); | |
int indent = 8; | |
foreach (string dir in Directories) | |
{ | |
string realdir = dir; | |
realdir = realdir.Replace (@"D:/Splitty WebServer/root/", ""); | |
realdir = realdir.Replace (@"\", "/"); | |
for (int i = 0; i < indent; i++) ReplaceString += " "; | |
ReplaceString += "<span class=\"packet\"><span class=\"dir\">Dir</span> " + realdir + "</span><br/>"; | |
string[] Files = Directory.GetFiles (dir); | |
indent += 4; | |
foreach (string file in Files) | |
{ | |
string realfile = file; | |
realfile = realfile.Replace (@"D:/Splitty WebServer/root/", ""); | |
realfile = realfile.Replace (@"\", "/"); | |
for (int i = 0; i < indent; i++) ReplaceString += " "; | |
ReplaceString += "<span class=\"packet\"><span class=\"file\">File</span> " + realfile + "</span><br/>"; | |
} | |
indent -= 4; | |
} | |
RootFile = RootFile.Replace ("$REPLACE", ReplaceString); | |
return Encoding.ASCII.GetBytes (RootFile); | |
} | |
catch | |
{ | |
StatusConsole.PrintLine ("Root file not found!", StatusConsole.WarningLevel.warning); | |
return GetFileContents (root, "404.html"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment