title: Access denied file in asp.net core
body: <p><br>
  When i publish my project to <code>iis</code> and i do upload a picture on browser so this operation is fails and show this error in <code>logger sysytem</code></p>
  
  <blockquote>
    <p>An unhandled exception has occurred: Access to the path 'C:\Inetpub\vhosts\qarbal.com\back.qarbal.com\wwwroot\images\UserProfile\pic_50.jpg' is denied.System.UnauthorizedAccessException: Access to the path 'C:\Inetpub\vhosts\qarbal.com\back.qarbal.com\wwwroot\images\UserProfile\pic_50.jpg' is denied.
       at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)</p>
  </blockquote>
  
  <p>ActionController</p>
  
  <pre><code>[HttpPost("[action]")]
  public async Task&lt;IActionResult&gt; EditPhoto()
  {
      var uploadsRootFolder = Path.Combine(_env.WebRootPath, "images\\UserProfile");
      var files = Request.Form.Files;     
      foreach (var file in files)
      {       
          if (file == null || file.Length == 0)
          {
              continue;
          }
          var filePath = Path.Combine(uploadsRootFolder, queryModel.Name  + files[0].FileName);
          using (var fileStream = new FileStream(filePath, FileMode.Create))
          {
              await file.CopyToAsync(fileStream).ConfigureAwait(false);
          }
      }
      return Json("ok");  
  }
  </code></pre>
  
  <p><code>startup.cs</code> </p>
  
  <pre><code>public void Configure(ILoggerFactory loggerFactory, IApplicationBuilder app, IHostingEnvironment env)
  {
      app.UseStaticFiles();
  }
  </code></pre>
  
  <p>How to solve this Exception ?</p>