public async Task List(HttpProcessor arg) { if (arg.Request.Query.ContainsKey("dir")) { var dir = arg.Request.Query["dir"]; if (!string.IsNullOrWhiteSpace(dir)) { if (!dir.EndsWith("\\")) { dir += "\\"; } var dirInfos = Directory.GetDirectories(dir).Select(x => { var attr = new System.IO.DirectoryInfo(x); return new StorageItemInfo(attr); }).ToList(); await arg.WriteJson(dirInfos); return; } } var drives = Directory.GetLogicalDrives(); var drivesInfo = drives.Select(x => { var attr = new System.IO.DirectoryInfo(x); return new StorageItemInfo(attr); }).ToList(); await arg.WriteJson(drivesInfo); }
public async Task List(HttpProcessor arg) { if (arg.Request.Query.ContainsKey("dir")) { var dir = arg.Request.Query["dir"]; if (!string.IsNullOrWhiteSpace(dir)) { if (!dir.EndsWith("\\")) { dir += "\\"; } var dirInfos = Directory.GetFiles(dir).Select(x => { var attr = new System.IO.DirectoryInfo(x); return new StorageItemInfo(attr); }).ToList(); await arg.WriteJson(dirInfos); return; } } await arg.WriteFail(HttpStatusCode.BadRequest); }