public static JQueryResponse CreateFolder(string folderName, string path) { if (ContainsInvalidCharacters(folderName)) { return(new JQueryResponse(500, "Folder names may not contain the following characters: " + HttpUtility.HtmlEncode(String.Join(",", InvalidPathChars)))); } var newPath = Path.Combine(path, folderName); // TODO: Expand with multiple file paths if (!newPath.StartsWith(Configuration.SiteSettings.Instance.FilePath)) { Logger.Write("Attempt to create folder '" + folderName + "' in path '" + path + "'!", Logger.Severity.Major); return(new JQueryResponse(500, "Access violation!")); } JQueryResponse returnValue; try { Directory.CreateDirectory(HttpContext.Current.Server.MapPath(newPath)); returnValue = new JQueryResponse(200, null); } catch (Exception exception) { Logger.Write(exception, Logger.Severity.Major); returnValue = new JQueryResponse(500, exception.Message); } return(returnValue); }
public static JQueryResponse CreateFolder(string folderName, string path) { if(ContainsInvalidCharacters(folderName)) { return new JQueryResponse(500, "Folder names may not contain the following characters: " + HttpUtility.HtmlEncode(String.Join(",", InvalidPathChars))); } var newPath = Path.Combine(path, folderName); // TODO: Expand with multiple file paths if (!newPath.StartsWith(Configuration.SiteSettings.Instance.FilePath)) { Logger.Write("Attempt to create folder '" + folderName + "' in path '" + path + "'!", Logger.Severity.Major); return new JQueryResponse(500, "Access violation!"); } JQueryResponse returnValue; try { Directory.CreateDirectory(HttpContext.Current.Server.MapPath(newPath)); returnValue = new JQueryResponse(200, null); } catch (Exception exception) { Logger.Write(exception, Logger.Severity.Major); returnValue = new JQueryResponse(500, exception.Message); } return returnValue; }