Abraham Olatubosun

Abraham Olatubosun

  • NA
  • 471
  • 114.7k

With Core 2.2, How to reference a file programmatically

Dec 27 2019 5:33 AM
Dear All,
 
Hope this question meet you all in good health and happy holiday,
 
I am trying to access a file from a folder programatically like this :
 
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Threading.Tasks;  
  5. using Microsoft.AspNetCore.Mvc;  
  6. using System.Data;  
  7. using System.Data.SqlClient;  
  8. using System.IO;  
  9. using System.Net.Http;  
  10. using System.Net.Http.Headers;  
  11. using System.Text;  
  12. using System.Text.RegularExpressions;  
  13. using System.Web;  
  14. using IQCARE_NMRS.PayLoads;  
  15. using Microsoft.Extensions.Configuration;  
  16. using MySql.Data.MySqlClient;  
  17. using Microsoft.AspNetCore.Hosting;  
  1. cmd.CommandText = System.IO.File.ReadAllText(HostingEnvironment.MapPath(Path.Combine("~/procedures""spGetEncountersAndLabs.sql")));  
  2.                         cmd.ExecuteNonQuery();  
the the above text in red is the error part i am need you guys to show me what am not doing right.
 
I need your help since i am new in asp.net core
 
Thanks 

Answers (1)