title: System.UnauthorizedAccessException: Access to the path '...' is denied
body: <p>So, I'm kinda new to .NET core and I'm having a problem to copy a IFormFile to a folder in my project. I've been trying to see other questions about it but none of the answers had helped me. That's my code:</p>
  
  <pre><code>public async Task&lt;string&gt; AddImage(IFormFile image, int id)
  {
      if (image.Length &gt; 0)
      {
          var filePath = Path.Combine("images", ("apartamento" + id.ToString()), image.FileName);
  
          if (!Directory.Exists(filePath))
          {
              Directory.CreateDirectory(filePath);
          }
  
          using (var fileStream = new FileStream(filePath, FileMode.Create))
          {
              await image.CopyToAsync(fileStream);
          }
  
          return filePath;
      }
  } 
  </code></pre>
  
  <p>The problem is that it seems that I don't have permission (tried hard to see if everything is authorized) or something about my code it's not right.</p>
  
  <p>I just wanna do a simple thing: receive an image in my API and save it so I can use in my project later. I have done it before but I'm facing some issues with .NET core.</p>
  
  <p>If someone have other idea to do it, I'll be thankful. I'm thinking about saving the image as Base64 in my database but I'm not sure about which is the best option. Or the easiest.</p>