How to pull file name from solution explorer? - In blazor server app/c sharp
I am creating an application which allows users to download pdf's which will be stored within the solution explorer - this works fine but is there any way of me pulling info from the file? - file name, folder name etc.
The code im using to download the file is as below if this helps.
the below code is in the @Aidan Wick section of my .razor file
async Task DownloadBinary()
{
FileStream fs = new FileStream("C://Development//CsharpApplications//AlbertBartletPortal//AlbertBartletPortal//PDFs//P45.pdf", FileMode.Open, FileAccess.Read);
byte[] pdfData = new byte[fs.Length];
fs.Read(pdfData, 0, Convert.ToInt32(fs.Length));
fs.Close();
// Send the data to JS to actually download the file
try
{
await JSRuntime.InvokeVoidAsync("BlazorDownloadFile", "P45.pdf", "application/octet-stream", pdfData);
}
catch(Exception ex)
{
}
}
this code displays a white card with a download image and if the user clicks it downloads the file and the following code is within the .razor file as well
`
<h1 class="text-center text-white pt-5">Purchase Order's</h1>
<div class="card-deck">
<div class="card" @onclick="DownloadBinary" style="color:white; width: 200px; height: 150px">
@*<img class="img-thumbnail" src="@item.ImageURL">*@
<div class="card-body">
<h5 class="card-title mb-3">
@*@item.Name*@
<p style="color: black"> Megan Paterson - p45</p>
</h5>
<p class="card-text">
@*<b>@item.Price.ToString("C")</b>*@
</p>
<center><img src="Images/img.png" width="40px" height="40px" /></center>
</div>
</div>
Once this is working, I will be pulling the foldername and using this to filter out the data.