Skip to content

Instantly share code, notes, and snippets.

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