.NET: FolderPicker zum
Auswählen eines Verzeichnisses
In C# einen Ordner auswählen
Notiz: leider werden angeschlossene USB Laufwerke von Smartphones nicht angezeigt
Wie kann man in Windows 10
einen Verzeichnis Dialog erstellen, zum Auswählen eines Ordner ?
Windows
FolderPicker Datei Dialog, Verzeichnis Dialog
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.
|
|