public string Get(string fileName = "") { // Response.ContentType = "application/json; charset=utf-8"; if (string.IsNullOrWhiteSpace(fileName)) { fileName = ""; } fileName = $"/{fileName.Trim('/')}"; var rootFileInfo = _fileProvider.GetFileInfo(fileName); IDirectoryContents dirContents = _fileProvider.GetDirectoryContents(fileName); if (rootFileInfo != null && rootFileInfo.Exists && !rootFileInfo.IsDirectory) { strBuilder.Append("{"); strBuilder.Append($"\"name\":\"{fileName.Trim('/').Split('/').LastOrDefault()}\","); strBuilder.Append($"\"path\":\"{fileName}\","); strBuilder.Append($"\"info\":"); strBuilder.Append("{"); strBuilder.Append($"\"lastModified\":\"{rootFileInfo.LastModified.LocalDateTime}\","); strBuilder.Append($"\"size\":\"{rootFileInfo.Length}\""); strBuilder.Append("}"); strBuilder.Append("}"); } else if (dirContents != null && dirContents.Exists) { strBuilder.Append("{"); strBuilder.Append($"\"name\":\"{fileName.Trim('/').Split('/').LastOrDefault()}\","); strBuilder.Append($"\"path\":\"{fileName}\","); strBuilder.Append("\"children\":["); if (dirContents.Count() > 0) { Render($"{fileName}"); strBuilder.Remove(strBuilder.Length - 1, 1); } strBuilder.Append("]"); strBuilder.Append("}"); } else { strBuilder.Append("{}"); } // JObject o = JObject.Parse(strBuilder.ToString()); //JArray categories = (JArray)o["children"][1]["children"]; //JArray categories2 = (JArray)o.SelectToken("children[1].children"); // Response.ContentType="application/json"; return(strBuilder.ToString()); // return Json(o); }