public void HandleChooseSetup(HttpListenerContext context) { context.Response.AppendHeader("Access-Control-Allow-Origin", "*"); ClockFileBrowser browser = new ClockFileBrowser(); var showListing = context.Request.QueryString["showListing"]; var dirName = context.Request.QueryString["dir"]; var dirPath = _myClockDisplay.clockAppConfig.CinemaRoot; var fullPath = context.Request.QueryString["fullpath"]; if (fullPath == "" || fullPath == null) { fullPath = dirPath; } switch (showListing) { case "fileListing": List <string> files = new List <string>(browser.getFileList(fullPath)); this.SendTextResponse(context, JsonConvert.SerializeObject(files)); break; default: List <string> dirs = new List <string>(browser.getDirectoryList(fullPath)); this.SendTextResponse(context, JsonConvert.SerializeObject(dirs)); break; } }
public void HandleDirList(HttpListenerContext context) { context.Response.AppendHeader("Access-Control-Allow-Origin", "*"); ClockFileBrowser browser = new ClockFileBrowser(); var showListing = context.Request.QueryString["showListing"]; var driveName = ""; var dirPath = ""; var dirName = ""; if (showListing == "" || showListing == null) { showListing = "driveListing"; } switch (showListing) { case "driveListing": List <string> drives = new List <string>(browser.getAllDrives()); this.SendTextResponse(context, JsonConvert.SerializeObject(drives)); break; case "dirListing": driveName = context.Request.QueryString["drive"]; if (driveName == "" && driveName == null) { this.SendTextResponse(context, "Invalid drive!"); } dirPath = driveName; dirName = context.Request.QueryString["dir"]; if (dirName != "" && dirName != null) { dirPath = Path.Combine(dirPath, dirName); } List <string> dirs = new List <string>(browser.getDirectoryList(dirPath)); this.SendTextResponse(context, JsonConvert.SerializeObject(dirs)); break; case "fileListing": driveName = context.Request.QueryString["drive"]; if (driveName == "" && driveName == null) { this.SendTextResponse(context, "Invalid drive!"); } dirPath = driveName; dirName = context.Request.QueryString["dir"]; if (dirName != "" && dirName != null) { dirPath = Path.Combine(dirPath, dirName); } List <string> files = new List <string>(browser.getFileList(dirPath)); this.SendTextResponse(context, JsonConvert.SerializeObject(files)); break; } }