I need to download a file from local folder using the partial file name,which is provided by the client side to the following function on Controller (RESTFUL API).
[HttpGet]
public IActionResult downloadTextFile(string partialName)
{
downloadTextFileFromLocal(partialName);
return null;
}
private static void downloadTextFileFromLocal(string partialName)
{
//string partialFileName = "2018-10-3";
DirectoryInfo hdDirectoryInWhichToSearch = new DirectoryInfo(@"D:\TextFile");
FileInfo[] filesInDir = hdDirectoryInWhichToSearch.GetFiles("*" + partialName + "*.*");
foreach (FileInfo foundFile in filesInDir)
{
string fullName = foundFile.FullName;
Console.WriteLine(fullName);
}
}
Using this there isn't any error but the file doesn't downloads. How can i do this?