I make my first steps into Angular and i am stuck with listing all files in ClientApp.
I have a Web Api on C# and GET request that shows all files in folder, but i dont know how to display that array in Angular.
[HttpGet]
[Route("/getAllFiles")]
public IEnumerable<string> GetAllFiles()
{
string folderName = "Upload";
string webRootPath = _hostingEnvironment.WebRootPath;
string newPath = Path.Combine(webRootPath, folderName);
List<string> files = new List<string>();
DirectoryInfo dirInfo = new DirectoryInfo(newPath);
foreach (FileInfo fInfo in dirInfo.GetFiles())
{
files.Add(fInfo.Name);
}
return files.ToArray();
}
I am trying to use this method, but i think i am wrong
return this.http.get(`https://localhost`)
this.http.get('https://localhost:3000/getAllFiles'). (Assuming the port is 3000).