Folder Browser Dialog

1 Answer 852 Views
General Discussions
Daniel
Top achievements
Rank 1
Silver
Bronze
Daniel asked on 06 Mar 2022, 10:33 AM | edited on 06 Mar 2022, 10:34 AM

Hi,

I'm using  VS is 17.2.0 Preview 1.0.

Maui Preview 13, Telerik nuget version is 0.5.0

Is there control FolderBrowserDialog that I can you un MAUI ?

Thanks in advance,

Lance | Manager Technical Support
Telerik team
commented on 08 Mar 2022, 04:03 PM

Hi Daniel, if noone has replied to your StackOverflow/Microsoft Q&A post, you can take a look at Microsoft's MAUI Essentials FilePicker control

Note: Microsoft hasn't published the documentation for MAUI Essentials yest, but you can use the same exact instructions from this documentation => Xamarin.Essentials: File Picker - Xamarin | Microsoft Docs  (MAUI Essentials are the same thing as Xamarin Essentials).

For an example, look at the MAUI Essentials demos maui/FilePickerViewModel.cs at main · dotnet/maui (github.com)

 
Daniel
Top achievements
Rank 1
Silver
Bronze
commented on 08 Mar 2022, 04:12 PM

i need folder not file picker.
Lance | Manager Technical Support
Telerik team
commented on 08 Mar 2022, 05:51 PM

Please read the material, just because it is called a "File" picker doesn't mean you cannot get a folder.  Or just Google/Bing the questions it and you'll see many conversations on the topic, here's the most recent one https://docs.microsoft.com/en-us/answers/questions/717736/folder-picker-in-xamarin-forms.html

It is also very important to remember that the mobile paradigm is VERY different than what you might be used to building WinForms or WPF apps. Mobile OS does not let you just get a full path due to the tighter security.

An easier way for you to do this would be just to show the user a list of safe folders that can select from using Environment.SpecialFolder enum Xamarin.Forms Directory Picker - Stack Overflow 

  
Daniel
Top achievements
Rank 1
Silver
Bronze
commented on 08 Mar 2022, 06:01 PM

i will.

I see also https://stackoverflow.com/questions/70999773/folder-picker-net-maui

Lance | Manager Technical Support
Telerik team
commented on 08 Mar 2022, 06:11 PM

That's a good starting point, you just need to finish building the interfaces for iOS and Android. Then on those native platform concrete implementations, you can use the native iOS and Android APIs to list the folder paths.

Though, keep in mind, you still run into the same risk of the user not being able to safe store anything in those locations You could look at the source code for MAUI Essentials and see how James implements the native iOS and and Android APIs to iterate valid directories. Here's the GitHub repo with the source code maui/src/Essentials at main · dotnet/maui (github.com)

Daniel
Top achievements
Rank 1
Silver
Bronze
commented on 09 Mar 2022, 03:01 PM

In my link the sample code is not complied.
Daniel
Top achievements
Rank 1
Silver
Bronze
commented on 09 Mar 2022, 03:07 PM

This code is not complied:



using WindowsFolderPicker = Windows.Storage.Pickers.FolderPicker;

namespace MauiFolderPickerSample.Platforms.Windows
{
    public class FolderPicker : IFolderPicker
    {
        public async Task<string> PickFolder()
        {
            var folderPicker = new WindowsFolderPicker();

            // Get the current window's HWND by passing in the Window object
            var hwnd = ((MauiWinUIWindow)App.Current.Windows[0].Handler.NativeView).WindowHandle;

            // Associate the HWND with the file picker
            WinRT.Interop.InitializeWithWindow.Initialize(folderPicker, hwnd);

            var result = await folderPicker.PickSingleFolderAsync();

            return result.Path;
        }
    }
}

Lance | Manager Technical Support
Telerik team
commented on 09 Mar 2022, 05:04 PM

Hi Daniel, you can get help on StackOverflow or Microsoft Q&A for .NET questions.

1 Answer, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 07 Mar 2022, 01:55 PM

Hi Daniel,

Telerik UI for MAUI does not have a FileBrowseDialog. You can ask this question on StackOverflow or Microsoft Q&A to discuss general .NET MAUI options.

Regards,
Lance | Manager Technical Support
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Lance | Manager Technical Support
Telerik team
commented on 18 Mar 2022, 04:27 PM

Daniel
Top achievements
Rank 1
Silver
Bronze
commented on 28 Apr 2022, 09:14 AM

In Rc1 it fixed see attached demo .
Daniel
Top achievements
Rank 1
Silver
Bronze
commented on 02 May 2022, 05:41 AM

Full demo include Window && Mac platforms.

https://github.com/jfversluis/MauiFolderPickerSample

Tags
General Discussions
Asked by
Daniel
Top achievements
Rank 1
Silver
Bronze
Answers by
Lance | Manager Technical Support
Telerik team
Share this question
or