• <metro>读取目录名


           首先,我们设计好一个Blank App程序,在添加Button和BlockText控件,在Button中找出Click事件,再单击进入事件。其中xaml中代码显示为:

     <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
            <Button x:Name="Folder" Content="Button" HorizontalAlignment="Left" Height="52" Margin="260,124,0,0" VerticalAlignment="Top" Width="183" Click="Folder_Click"/>
            <TextBlock x:Name="Foutput" HorizontalAlignment="Left" Height="136" Margin="260,225,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="444"/>
    
        </Grid>

          其次,用FolderPicker类new一个实例folderPicker ,在调用属性 SuggestedStartLocation设定起始位置。接着用FileTypeFilter.Add增加可以识别的文件类型。再用StorageFolder类新建一个实例,等待异步PickSingleFolderAsync方法, 获得一个目录。 通过StorageApplicationPermissions.FutureAccessList.AddOrReplace方法,得到选择的目录权限。最后,将它的目录名显示到BlockText中。按F5演示成功。其中事件中代码如下:

          private async void Folder_Click(object sender, RoutedEventArgs e)
            {
                FolderPicker folderPicker = new FolderPicker();
                folderPicker.SuggestedStartLocation = PickerLocationId.Desktop;
                folderPicker.FileTypeFilter.Add(".docx");
                folderPicker.FileTypeFilter.Add(".xlsx");
                folderPicker.FileTypeFilter.Add(".pptx");
    
                StorageFolder folder = await folderPicker.PickSingleFolderAsync();
                if (folderPicker != null)
                {
                    StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);
                    Foutput.Text = "Picked folder: " + folder.Name;
                }
                else
                {
                    Foutput.Text = "Operation cancelled.";
                }
    
            }
  • 相关阅读:
    【交互稿】sample
    【公开数据】网站
    【交互】规范
    【Flask】https
    【Flask】run with ssl /https
    需求模版
    低功耗蓝牙BLE外围模式(peripheral)-使用BLE作为服务端
    AIDL示例
    Android使用BLE(低功耗蓝牙,Bluetooth Low Energy)
    Android网络访问库
  • 原文地址:https://www.cnblogs.com/virgil/p/2748113.html
Copyright © 2020-2023  润新知