How to request authorization from macOS to delete file in MAUI Mac Catalyst app

Bohdan Rieznikov 5 Reputation points
2024-03-26T21:54:18.49+00:00

I have MAUI application that deletes file. But I can get UnathorizedException, because file is secured. I want a dialog to appear for user "Application NAME_OF_MY_APP wants to delete FILE", like Finder does when you want to delete some protected file, and user authenticates and permit it. How can I implement this functionality in MAUI?

if (Directory.Exists(Path.Combine(newFolderPath, "FirstDigitalSigner.app", "Contents", "Frameworks", "libSkiaSharp.framework", "Versions", "Current"))) {

Directory.Delete(Path.Combine(newFolderPath, "FirstDigitalSigner.app", "Contents", "Frameworks", "libSkiaSharp.framework", "Versions", "Current"), true); // Here I am getting UnathorizedException because programm does not authorized to do it. How to request authorization for it?

}

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,375 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,869 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,249 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,026 Reputation points
    2024-03-27T02:33:14.1933333+00:00

    You use the native FileManger with authorization. But I’m not sure it’s supported in the catalyst sandbox.

    https://developer.apple.com/documentation/foundation/filemanager/3025773-init

    1 person found this answer helpful.