public static async Task<bool> DisplayApplicationPicker(string folderName, string fileName)
{
// Path to the file in the app package to launch MessageDialog message = null;
StorageFolder storageFolder = null;
StorageFile GetStorageFile = null; IReadOnlyList<StorageFolder> storageFolders; bool isExist = false;
try
{ try
{ //在指定的应用程序文件夹下查找指定的文件
storageFolder = ApplicationData.Current.LocalFolder;
storageFolders = await storageFolder.GetFoldersAsync();
isExist = storageFolders.Any(folder => folder.Name == folderName);
if (isExist)
{
storageFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync(folderName); }
else
{
storageFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(folderName);
} }
catch (System.IO.FileNotFoundException ex)
{
message = new MessageDialog(ex.Message);
message.ShowAsync();
}
//判断是否有该文件
try
{
//在指定的应用程序文件夹下查找指定的文件
if (isExist)
{
IReadOnlyList<StorageFile> files = await storageFolder.GetFilesAsync();
bool isExistfile = files.Any(file => file.Name == fileName);
if (!isExistfile)
{
message = new MessageDialog("Didn't find the specified file");
message.ShowAsync();
//todo: Written to the file Method
}
else
{
GetStorageFile = await storageFolder.GetFileAsync(fileName);
} } }
catch (System.IO.FileNotFoundException ex)
{
message = new MessageDialog(ex.Message);
message.ShowAsync();
} if (GetStorageFile != null)
{
// Set the option to show the picker
var options = new Windows.System.LauncherOptions();
options.DisplayApplicationPicker = true; // Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(GetStorageFile, options); if (success)
{
// File launched
return true; }
else
{
// File launch failed
message = new MessageDialog("Please choose other open way");
message.ShowAsync();
return false; }
}
else
{
message = new MessageDialog( "Didn't find the specified file");
message.ShowAsync();
return false;
} }
catch (Exception ex)
{
message = new MessageDialog(ex.Message);
message.ShowAsync();
return false;
} }

window store app 附件读取的更多相关文章

  1. 在桌面程序上和Metro/Modern/Windows store app的交互(相互打开,配置读取)

    这个标题真是取得我都觉得蛋疼..微软改名狂魔搞得我都不知道要叫哪个好.. 这边记录一下自己的桌面程序跟windows store app交互的过程. 由于某些原因,微软的商店应用的安全沙箱导致很多事情 ...

  2. Windows store app[Part 1]:读取U盘数据

    Windows 8系统下开发App程序,对于.NET程序员来说,需要重新熟悉下类库. 关于WinRT,引用一张网上传的很多的结构图: 图1 针对App的开发,App工作在系统划定的安全沙箱内,所以通过 ...

  3. Windows 8.1 store app 开发笔记

    原文:Windows 8.1 store app 开发笔记 零.简介 一切都要从博彦之星比赛说起.今年比赛的主题是使用Bing API(主要提到的有Bing Map API.Bing Translat ...

  4. 05、Windows Store app 的图片裁切(更新)

    在 Win Phone Silverlight api 中,有一个 PhotoChooserTask 选择器,指定宽.高属性,在选择图片的时候, 可以进行裁切,代码: PhotoChooserTask ...

  5. Windows store app[Part 3]:认识WinRT的异步机制

    WinRT异步机制的诞生背景 当编写一个触控应用程序时,执行一个耗时函数,并通知UI更新,我们希望所有的交互过程都可以做出快速的反应.流畅的操作感变的十分重要. 在连接外部程序接口获取数据,操作本地数 ...

  6. 吐槽坑爹的微软win store app审核

    从学习win store app 开发到做出第一个应用 博客园cnblogs 花了一个多月的全部业余和上班空闲时间, 上周在端午节放假期间终于完成了计划的全部开发和测试, 6月10号怀着无比激动的心情 ...

  7. Windows Store App 过渡动画

    Windows Store App 过渡动画     在开发Windows应用商店应用程序时,如果希望界面元素进入或者离开屏幕时显得自然和流畅,可以为其添加过渡动画.过渡动画能够及时地提示用户屏幕所发 ...

  8. 09、win32 转换为 store app

    1.机制: 微软的 Project Centernial ( Project C) 项目的就是把传统的 windows桌面应用程序 转换为 windows10 store app (appx). 目的 ...

  9. 01、Windows Store APP 设置页面横竖屏的方法

    在 windows phone store app 中,判断和设置页面横竖屏的方法,与 silverlight 中的 Page 类 不同,不能直接通过 Page.Orientation 进行设置.而是 ...

随机推荐

  1. LeetCode32 Longest Valid Parentheses

    题目: Given a string containing just the characters '(' and ')', find the length of the longest valid ...

  2. sql查询行转列

    昨天下午碰到一个需求,一个大约30万行的表,其中有很多重复行,在这些行中某些字段值是不重复的. 比如有ID,NAME,CONTRACT_id,SALES,PRODUCT等,除了PRODUCT字段,其余 ...

  3. uiview 的setAnimationTransition : forView 方法实现翻页效果

    [UIView beginAnimations:nil context:nil]; [UIView setAnimationTransition:UIViewAnimationTransitionCu ...

  4. Java Set接口

    Set 集合不能包含重复的元素的集合.该模型数学抽象集合. Set接口只包含继承自Collection的方法,并增加了重复的元素被禁止约束性. 集还增加了对equals和hashCode操作的行为更强 ...

  5. html&css&js随笔-问题集锦

    1.IE6/7不支持display:inline_block属性:(解决办法) ;*display:inline;} 给元素增加*zomm和*display即可: 2.IE监听事件与W3C标准不一致: ...

  6. makefile文件的技术

    [快速的学习笔记] gcc命令:http://www.cnblogs.com/ggjucheng/archive/2011/12/14/2287738.html#_Toc311642845 makef ...

  7. 社交分享:-canOpenURL: failed for URL: "weixin://app/*************/" - error: "This app is not allowed to query for scheme weixin"

    升级到iOS9后,微信,QQ,微博等社交软件的分享都失效了,控制台默默地打印了这条信息: This app is not allowed to query for scheme xxx 这是因为iOS ...

  8. Java基础--访问权限控制符

    今天我们来探讨一下访问权限控制符. 使用场景一:攻城狮A编写了ClassA,但是他不想所有的攻城狮都可以使用该类,应该怎么办? 使用场景二:攻城狮A编写了ClassA,里面有func1方法和func2 ...

  9. 剑指Offer28 最小的K个数(Partition函数应用+大顶堆)

    包含了Partition函数的多种用法 以及大顶堆操作 /*********************************************************************** ...

  10. LeetCode 287

    Find the Duplicate Number Given an array nums containing n + 1 integers where each integer is betwee ...