/// <summary> /// Fetch a list of files and folders at the specified 'path'. /// </summary> /// <param name="path"></param> /// <param name="offset"></param> /// <param name="limit"></param> /// <param name="sortBy"></param> /// <param name="sortDirection"></param> /// <param name="fileType"></param> /// <param name="onlyWritable"></param> /// <param name="additional"></param> /// <returns></returns> public async Task <DataModel <FilesModel> > ListAsync(string path, int offset = 0, int limit = 0, SortBy sortBy = SortBy.Name, SortDirection sortDirection = SortDirection.Ascending, string fileType = "all", bool onlyWritable = false, string[] additional = null) { if (String.IsNullOrWhiteSpace(path)) { throw new ArgumentException($"Argument cannot be null, empty or whitespace.", nameof(path)); } _logger.LogDebug($"Making HTTP request to fetch a list"); if (String.IsNullOrWhiteSpace(_sid)) { await AuthenticateAsync(); } var values = new Dictionary <string, string>() { { "api", "SYNO.FileStation.List" }, { "version", "2" }, { "method", "list" }, { "_sid", _sid }, { "offset", $"{offset}" }, { "limit", $"{limit}" }, { "sort_by", sortBy.GetValue() }, { "sort_direction", sortDirection.GetValue() }, { "onlywritable", $"{onlyWritable}" }, { "additional", $"[\"{String.Join("\",\"", additional ?? new string [0])}\"]" }, { "action", "list" }, { "check_dir", "true" }, { "filetype", fileType }, { "folder_path", path }, }; var form = new FormUrlEncodedContent(values); var response = await _client.PostAsync(Path("entry"), form); return(await HandleResponseAsync <FilesModel>(response)); }