I am creating an ASP.NET MVC web application that serializes JSON files for user-inputed information. The base template that I was following operates like this:
string jsonData = JsonConvert.SerializeObject(rootObject);
string path = Server.MapPath("~/App_Data/");
System.IO.File.WriteAllText(path + ticket.TicketNumber + ".json", jsonData);
TempData["msg"] = " Json file Generated! Json files generated here can be found in *** ";
return RedirectToAction("Index");;
As I started to try to figure out how to add a method for the user to input where they would like to save their file locally (for an easy way for them to check in the file to TFS rather than moving the file from the app data folder to their desired folder) I realized that this only operates within the web app's directory. Is there something other than Server.MapPath(); that I can use to specify a location in a user's C:\ drive or not?