Skip to content

Instantly share code, notes, and snippets.

@liebki
Created January 21, 2022 12:35
Show Gist options
  • Save liebki/5ab227f36909b0338bb76d90be76926a to your computer and use it in GitHub Desktop.
Save liebki/5ab227f36909b0338bb76d90be76926a to your computer and use it in GitHub Desktop.
Custom component for razor (blazor server-side), to read folders (or files) in local filesystem
@code {
[Parameter]
public string? path { get; set; }
}
<h3>Folders in @path</h3>
<ul>
@foreach(string folder in data) {
<li>@folder</li>
}
</ul>
@code {
public string[]? data { get; set; }
protected override async Task OnInitializedAsync()
{
string[] readData = new string[0];
if(path != null)
{
readData = Directory.GetDirectories(@path);
}
data = readData;
StateHasChanged();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment