MAUI - File picker - option to only to choose file and no more

דני שטרית 1,736 Reputation points
2023-05-03T06:49:20.8+00:00

Hi,

Option to only to choose file and not allowed to make any other operation of copy/cut/delete

of files.

Thanks,

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,206 questions
{count} votes

Accepted answer
  1. Rob Caplan - MSFT 5,387 Reputation points Microsoft Employee
    2023-05-09T17:36:23.8633333+00:00

    From your screenshot, I believe you're working in Windows here. The Windows file picker hosts a fully operational shell view which allows standard shell operations within its scope. These operations use the permissions of the current user.

    The file picker does not provide any way to prevent this.

    If you want the user to be able to pick files without being able to copy/cut/delete from the picker then you will need to write your own file picker by enumerating the file system and creating your own UI to display them and let the user choose.

    A custom picker will be subject to the app's permissions and will not be able to extend permissions that the app doesn't have on its own. This won't have a significant impact in most WinUI3 apps, since WinUI3 defaults to running with the user's permissions. It will limit iOS and Android apps which run restricted.

    I want to block malicious for copy files from the computer and insert it to file picker/folder?

    The file picker wont' allow the user to copy or change any files that they couldn't do anyway. This isn't a security barrier. If users shouldn't be able to manipulate the files then that needs to be blocked by appropriate security settings at the system level. This is a system administration function outside of the scope of a normal application.


0 additional answers

Sort by: Most helpful