zoukankan      html  css  js  c++  java
  • <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.";
                }
    
            }
  • 相关阅读:
    Java入门第二阶段总结
    POj3017 dp+单调队列优化
    CH5701 开车旅行(倍增dp+set)
    dp优化---四边形不等式与决策单调性
    CH5E07 划分大理石(背包dp+二进制拆分)
    POJ1185 炮兵阵地(状压dp)
    CH5501 环路运输(单调栈)
    poj3585 Accumulation Degree(换根dp)
    CH5105 Cookies (线性dp)
    反射
  • 原文地址:https://www.cnblogs.com/virgil/p/2748113.html
Copyright © 2011-2022 走看看