Can I write a file to a folder on a server machine from a Web API app running on it?

前端 未结 2 1331
失恋的感觉
失恋的感觉 2021-02-14 14:59

I have this code in my Web API app to write to a CSV file:

private void SaveToCSV(InventoryItem invItem, string dbContext)
{
    string csvHeader = \"id,pack_siz         


        
2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-14 15:31

    Thanks to Patrick Hofman; this is the exact code I am using, and it is saved to the project's App_Data folder:

    public static string appDataFolder = HttpContext.Current.Server.MapPath("~/App_Data/");
    . . .
    string csvFilename = string.Format("Platypus{0}.csv", dbContextAsInt);
    string fullSavePath = string.Format("{0}{1}", appDataFolder, csvFilename);
    

提交回复
热议问题