How to display only folders using Blazor FileManager.

Answer:

We can display only folders using FileManager by the return response for FileManager component.
Please, refer to the below code snippet.

case "read":

// reads the file(s) or folder(s) from the given path.

//return this.operation.ToCamelCase(this.operation.GetFiles(args.Path, args.ShowHiddenItems));

FileManagerResponse readResult = this.operation.GetFiles(args.Path, args.ShowHiddenItems);

List newFiles = new List();

foreach (FileManagerDirectoryContent file in readResult.Files)

{

if ((file.Type == ""))

{

newFiles.Add(file);

}

}

readResult.Files = newFiles;

return Json(operation.ToCamelCase(readResult));

case "search":

// gets the list of file(s) or folder(s) from a given path based on the searched key string.

//return this.operation.ToCamelCase(this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive));

FileManagerResponse searchResult = this.operation.Search(args.Path, args.SearchString, args.ShowHiddenItems, args.CaseSensitive);

List new_searchFiles = new List();

foreach (FileManagerDirectoryContent file in searchResult.Files)

{

if ((file.Type == ""))

{

new_searchFiles.Add(file);

}

}

searchResult.Files = new_searchFiles;

return Json(this.operation.ToCamelCase(searchResult));

Find the sample for display only folders using Blazor FileManager from here.

Loader.
Up arrow icon