Created
January 21, 2022 12:35
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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