Created
September 2, 2016 13:12
-
-
Save mikebrind/e42dca7e3cded9990c20627a7ca9e9f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.Mvc; | |
namespace IHostingEnvironmentExample.Controllers | |
{ | |
public class HomeController : Controller | |
{ | |
private IHostingEnvironment _env; | |
public HomeController(IHostingEnvironment env) | |
{ | |
_env = env; | |
} | |
public IActionResult Index() | |
{ | |
var webRoot = _env.WebRootPath; | |
var file = System.IO.Path.Combine(webRoot, "test.txt"); | |
System.IO.File.WriteAllText(file, "Hello World!"); | |
return View(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment