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 进行设置.而是 ...
随机推荐
- CentOS6.3配置yum源
转载:http://www.linuxidc.com/Linux/2012-10/72750.htm 全新以最小化包安装了64位的CentOS6.3系统,作为本地的Web服务器使用,现记录全过程第二步 ...
- java操作spark1.2.0
虽然推荐的是scala,但是还是试一下 package org.admln.java7OperateSpark; import java.util.Arrays; import java.util.L ...
- .Net Static 与单例
Static 关键字作为修饰符可以用于类.方法和成员变量上.其含义是对于整个应用程序生命周期内,访问该修饰符修饰的对象/方法/变量都引用到同一实例(内存地址).但正因如此在多线程下会出现线程安全问题: ...
- 【Mood-8】IT男!五更天!
男人从毕业到30岁之间所承受的叠加的压力,赡养父母.结婚生子.升职加薪.工作压力.生活质量,这些东西可以压得我们喘不过起来,也成为我们成长的动力, 我们累,但不说累,我们闷着头做事儿,不张扬,但每个都 ...
- NSURLConnection & NSRULSession
NSURLConnection & NSRULSession NSURLSession是NSURLConnection 的替代者,在2013年苹果全球开发者大会(WWDC2013)随ios7一 ...
- Redis入门(优势,环境,字符串,哈希,列表)
Redis从它的许多竞争继承来的三个主要特点: Redis数据库完全在内存中,使用磁盘仅用于持久性. 相比许多键值数据存储,Redis拥有一套较为丰富的数据类型. Redis可以将数据复制到任意数量的 ...
- 元数据metadata 对IO有多大影响
日志文件系统(journaling file systems)可防止系统崩溃时导致的数据不一致问题.对文件系统元数据(metadata)的更改都被保存在一份单独的日志里,当发生 系统崩溃时可以根据日志 ...
- gcc: error trying to exec 'cc1plus': execvp: no such file or directory
最近在安装OpenCV cmake的时,出现gcc: error trying to exec 'cc1plus': execvp: no such file or directory的错误. 导致问 ...
- Gulp 自动化的项目构建工具
在很多场合都会听到前端工和 node 程师推荐 Grunt 来实现项目的自动化,自动化可以自动完成 javascript/coffee/sass/less 等文件的的测试.检查.合并.压缩.格式化.部 ...
- hdu 4118 树形dp
思路:其实就是让每一条路有尽量多的人走. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<m ...