title: UnauthorizedAccessException when creating a file
body: <p>I'm getting UnauthorizedAccessException when I trying to save an uploaded file from my blazor server application.</p>
  <p>I had used the same code of the <a href="https://docs.microsoft.com/it-it/aspnet/core/blazor/file-uploads?view=aspnetcore-6.0&amp;pivots=server" rel="nofollow noreferrer">Microsoft docs</a></p>
  <p>I'm using a Macbook and my OS is macOS Monterey 12.3.1</p>
  <p>I try to set &quot;everyone&quot; permissions to &quot;Read and Write&quot; already, but nothing has changed.</p>
  <p>Someone have a suggestion/solution?</p>
  <pre><code>private async Task loadFile(InputFileChangeEventArgs e) {
  
      loading = true;
  
      var file = e.File;
  
      var trustedFileNameForFileStorage = Path.GetRandomFileName();
      var path = Path.Combine(Environment.ContentRootPath,
              Environment.EnvironmentName, &quot;unsafe_uploads&quot;);
  
      DirectoryInfo di = new DirectoryInfo(path);
  
  
      try
      {
          if (!di.Exists)
          {
              di.Create();
          }
  
          await using FileStream fs = new(path, FileMode.Create);
          await file.OpenReadStream().CopyToAsync(fs);
      }
      catch (Exception ex)
      {
  
      }
  }
  </code></pre>