1

I'm experimenting with syncing photos between two cloud providers, first I wanted a local list of photos on my Mac.

I'm using .Net 5 on MacOs

However, Big Sur is preventing my app from accessing the Pictures directory, .Net is giving me a System.UnauthorizedAccessException.

How do I allow my .Net application access to the full hard drive on a Mac ?

Code below, I can quite happily hit Documents with this code, but Big Sur doesn't like me accessing Pictures.

using System;
using System.IO;

namespace FindFiles
{
    class Program
    {
        static void Main(string[] args)
        {

            var x = Directory.GetFiles("/Users/paul/Pictures", "*" , SearchOption.AllDirectories);

            Console.WriteLine(x.Length);
           
        }
    }
}

Thanks

paul1923
  • 431
  • 3
  • 17

1 Answers1

3

I solved this myself, I was looking to add the dotnet command as an allowed program in "Full Disk Access", however in the end it was trivial fix.

It was as simple as giving Visual Studio itself Full Disk Access.

Visual Studio Full Disk Access

In addition, because I'd already given terminal full disk access, I found that I could run "dotnet run" from terminal, from the VS project folder, without problems.

paul1923
  • 431
  • 3
  • 17