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 进行设置.而是 ...
随机推荐
- SQL(基于MySQL)——LIMIT用法
mysql支持limitselect * from tablename limit n,mn:表示从第几行开始,mysql的行数是从0开始标注. m:表示要显示几行: 例如:select * from ...
- C# 自定义重绘TextBox
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...
- Asp.NET 之 路径浅析
比如你的工程是Web(url是:http://localhost/web/default.aspx) Request.ApplicationPath 就是/Web 如果是站点就直接返回"/& ...
- Windows下memcache安装使用
Windows下Memcache安装 随着时间的推移,网上现在能找到的在 Windows下安装 Memcache 的文档大多已经过时.雪峰这里再简要介绍一下当下最新版的安装和配置方法. Memcach ...
- 1.4.2 solr字段类型--(1.4.2.4)使用Dates(日期)
1.4.2 solr字段类型 (1.4.2.1) 字段类型定义和字段类型属性. (1.4.2.2) solr附带的字段类型 (1.4.2.3) 使用货币和汇率 (1.4.2.4) 使用Dates(日期 ...
- 在项目中使用SQLite数据库小结
------------------------------------------------------------------------推荐: - VS2012 使用 1.0.84 版的库 - ...
- HDU 1087 Super Jumping! Jumping! Jumping! (DP)
C - Super Jumping! Jumping! Jumping! Time Limit:1000MS Memory Limit:32768KB 64bit IO Format: ...
- itunes connect提交app教程
.打开itunes connect登陆之后,选择Manage Your Apps,再选Add New App: .填写项目相关信息,不知道怎么填的点击问号查看: Bundle ID Suffix需要和 ...
- Ajax异步操作集合啦(阿贾克斯)
/* * Ajax的核心操作对象是xmlHttpRequest * 简化操作步骤:实例化一个xmlHttpRequest对象 ==> 发送请求 ==> 接受响应 ==> 执行回调 * ...
- 【CSS3】---text-overflow 与 word-wrap
text-overflow用来设置是否使用一个省略标记(...)标示对象内文本的溢出. 语法: 但是text-overflow只是用来说明文字溢出时用什么方式显示,要实现溢出时产生省略号的效果,还须定 ...