window store app 附件读取
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 附件读取的更多相关文章
- 在桌面程序上和Metro/Modern/Windows store app的交互(相互打开,配置读取)
这个标题真是取得我都觉得蛋疼..微软改名狂魔搞得我都不知道要叫哪个好.. 这边记录一下自己的桌面程序跟windows store app交互的过程. 由于某些原因,微软的商店应用的安全沙箱导致很多事情 ...
- Windows store app[Part 1]:读取U盘数据
Windows 8系统下开发App程序,对于.NET程序员来说,需要重新熟悉下类库. 关于WinRT,引用一张网上传的很多的结构图: 图1 针对App的开发,App工作在系统划定的安全沙箱内,所以通过 ...
- Windows 8.1 store app 开发笔记
原文:Windows 8.1 store app 开发笔记 零.简介 一切都要从博彦之星比赛说起.今年比赛的主题是使用Bing API(主要提到的有Bing Map API.Bing Translat ...
- 05、Windows Store app 的图片裁切(更新)
在 Win Phone Silverlight api 中,有一个 PhotoChooserTask 选择器,指定宽.高属性,在选择图片的时候, 可以进行裁切,代码: PhotoChooserTask ...
- Windows store app[Part 3]:认识WinRT的异步机制
WinRT异步机制的诞生背景 当编写一个触控应用程序时,执行一个耗时函数,并通知UI更新,我们希望所有的交互过程都可以做出快速的反应.流畅的操作感变的十分重要. 在连接外部程序接口获取数据,操作本地数 ...
- 吐槽坑爹的微软win store app审核
从学习win store app 开发到做出第一个应用 博客园cnblogs 花了一个多月的全部业余和上班空闲时间, 上周在端午节放假期间终于完成了计划的全部开发和测试, 6月10号怀着无比激动的心情 ...
- Windows Store App 过渡动画
Windows Store App 过渡动画 在开发Windows应用商店应用程序时,如果希望界面元素进入或者离开屏幕时显得自然和流畅,可以为其添加过渡动画.过渡动画能够及时地提示用户屏幕所发 ...
- 09、win32 转换为 store app
1.机制: 微软的 Project Centernial ( Project C) 项目的就是把传统的 windows桌面应用程序 转换为 windows10 store app (appx). 目的 ...
- 01、Windows Store APP 设置页面横竖屏的方法
在 windows phone store app 中,判断和设置页面横竖屏的方法,与 silverlight 中的 Page 类 不同,不能直接通过 Page.Orientation 进行设置.而是 ...
随机推荐
- 解决vim中鼠标右键无法复制的问题
转:http://www.cnblogs.com/jianyungsun/archive/2011/03/19/1988855.html 这是我的vim配置文件:jeffy-vim-v2.4.tar ...
- UIView的生命周期总结
序言: loadView.viewDidLoad.viewDidAppear.initWithNibName.awakeFromNib等经常出现在UIViewController中的方法介绍. 这些方 ...
- C#基础--.net平台的重要组成部分以及.net程序简单的编译原理
.net平台的组成只要有两部分 FCL:框架类库 CLR:公共语言运行时 .net程序简单的编译原理 1.0:使用C#编译器(csc.exe) 将C#源代码编译成程序集+{编译之前:会检查C ...
- iOS tabbar 控制器基本使用
RootViewController *rootVC=[[RootViewController alloc] init] SignInViewController *signVC = [[SignIn ...
- uva 10054 The Necklace 拼项链 欧拉回路基础应用
昨天做了道水题,今天这题是比较水的应用. 给出n个项链的珠子,珠子的两端有两种颜色,项链上相邻的珠子要颜色匹配,判断能不能拼凑成一天项链. 是挺水的,但是一开始我把整个项链看成一个点,然后用dfs去找 ...
- 重构21-Collapse Hierarchy(去掉层级)
我们通过提取子类来下放职责.,当我们意识到不再需要某个子类时,可以使用Collapse Hierarchy重构.如果某个子类的属性(以及其他成员)可以被合并到基类中,这时再保留这个子类已经没有任何意义 ...
- 剑指Offer18 顺时针打印矩阵
/************************************************************************* > File Name: 18_PrintM ...
- hdu 4144 状态压缩dp
#include<map> #include<set> #include<cmath> #include<queue> #include<cstd ...
- Pascal 语言中字符与字符串
[题目]输入一段文章(255个字符以内),求文章中单词的个数,相同单词只记一次,The 和 the 视作相同. [敲代码] //网友代码 var article,w:string; arr:array ...
- Linux apache日志分析常用命令汇总
1.查看当天有多少个IP访问: awk '{print $1}' log_file|sort|uniq|wc –l 2.查看某一个页面被访问的次数: grep "/index.php&quo ...