Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

NET: FolderPicker zum Auswählen eines Verzeichnisses

04.12.2020 (👁9282)

.NET: FolderPicker zum Auswählen eines Verzeichnisses

In C# einen Ordner auswählen

Wie kann man in Windows 10 einen Verzeichnis Dialog erstellen, zum Auswählen eines Ordner ?

Windows FolderPicker, Folder Dialog


Notiz: leider werden angeschlossene USB Laufwerke von Smartphones nicht angezeigt


Code Beispiel wie unten gezeigt in der Auswahl

       private async void btnReadFolder_Click(object sender, RoutedEventArgs e)

        {

            var folderPicker = new Windows.Storage.Pickers.FolderPicker();

            folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;

            folderPicker.FileTypeFilter.Add("*");

            Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync();

            if (folder != null)

            {

                // Application now has read/write access to all contents in the picked folder

                // (including other sub-folder contents)

                Windows.Storage.AccessCache.StorageApplicationPermissions.

                FutureAccessList.AddOrReplace("PickedFolderToken", folder);

                txtBlock.Text = "Picked folder: " + folder.Name;

            }

            else

            {

                txtBlock.Text = "Operation cancelled.";

            }

        }

Und beim Auswählen eines Ordners:

Watch auswertung

Name

Value

Type

folder

{Windows.Storage.StorageFolder}

Windows.Storage.StorageFolder

Attributes

Directory

Windows.Storage.FileAttributes

 DateCreated

{12/4/2020 3:20:26 PM +01:00}

System.DateTimeOffset

DisplayName

"Xaml-Controls-Gallery-winui3preview"

string

DisplayType

"Dateiordner"

string

FolderRelativeId

"40554450839AD709\\Xaml-Controls-Gallery-winui3preview"

string

Name

"Xaml-Controls-Gallery-winui3preview"

string

Path

"D:\\Programmierung\\WinUI3\\Xaml-Controls-Gallery-winui3preview"

string

 Properties

{Windows.Storage.FileProperties.StorageItemContentProperties}

Windows.Storage.FileProperties.StorageItemContentProperties

Provider

{Windows.Storage.StorageProvider}

Windows.Storage.StorageProvider

Native View

To inspect the native object, enable native code debugging.