I believe what you're looking for is something like
var trustedFileNameForFileStorage = Path.GetRandomFileName();
var path = Path.Combine(env.ContentRootPath,
env.EnvironmentName, "unsafe_uploads",
trustedFileNameForFileStorage);
Path is using the System.IO namespace and env is from an injected instance of IWebHostEnvironment
A full example can be found at: https://docs.microsoft.com/en-us/aspnet/core/blazor/file-uploads?view=aspnetcore-5.0&pivots=server
Posted 2 years ago
by selliott