上一篇文章小梦分享了文件选择器FileOpenPicker的用法,这篇文章我们继续分享FileSavePicker的用法,FileSavePicker的用法几乎和FileOpenPicker用法一模一样.唯一的区别就是在FileOpenPicker中是通过FileTypeFilter属性添家字符串元素的,但是在FileSavePicker中是向FileTypeChoices属性表示的集合中添加元素的.FileTypeChoices是字典类型,因此它的每一个元素都必须具有唯一的键名,对应的值是IList<string>类型.

下面我们通过将textbox的内容存入一个txt文件来说明FileSavePicker的用法,过程和FileOpenPicker用法是一样的.

就把代码依次贴出来了:

   private void saveButton_Click(object sender, RoutedEventArgs e)
{
FileSavePicker savePicker = new FileSavePicker(); savePicker.FileTypeChoices.Add("TXT", new List<string>() { ".txt" }); savePicker.SuggestedFileName = "小梦";
savePicker.ContinuationData["Operation"] = "Save";
savePicker.PickSaveFileAndContinue();
}
protected override void OnActivated(IActivatedEventArgs args)
{
if (args is FileSavePickerContinuationEventArgs)
{
Frame rootFrame = Window.Current.Content as Frame;
if (!rootFrame.Navigate(typeof(MainPage)))
{
throw new Exception("Failed to create target page");
} var s = rootFrame.Content as MainPage;
s.SavePickerArgs = (FileSavePickerContinuationEventArgs)args; }
Window.Current.Activate();
}
private FileSavePickerContinuationEventArgs savePickerArgs;
public FileSavePickerContinuationEventArgs SavePickerArgs
{
get { return savePickerArgs; }
set
{
savePickerArgs = value;
ContinuFileSavePicker(savePickerArgs);
}
} private async void ContinuFileSavePicker(FileSavePickerContinuationEventArgs args)
{
if (args.ContinuationData["Operation"] as string == "Save" && args.File != null)
{
StorageFile txtFile = args.File; await FileIO.WriteTextAsync(txtFile, this.text.Text.ToString(), Windows.Storage.Streams.UnicodeEncoding.Utf8); } }

windows phone 8.1开发:文件选择器FileSavePicker的更多相关文章

  1. windows phone 8.1开发:文件选择器FileOpenPicker

    原文出自:http://www.bcmeng.com/fileopenpicker/ 今天小梦给大家分享一下 windows phone 8.1中的文件选择器,和之前的windows phone8的不 ...

  2. Windows Store App JavaScript 开发:文件选取器

    正如前面章节C#语言中所介绍的,文件选取器是应用与系统进行交互的一个接口,通过文件选取器可以在应用中直接与文件系统进行交互,访问不同位置的文件或文件夹,或者将文件存储在指定位置.文件选取器分为对文件进 ...

  3. Windows Phone 8初学者开发—第21部分:永久保存Wav音频文件

    原文 Windows Phone 8初学者开发—第21部分:永久保存Wav音频文件 第21部分:永久保存Wav音频文件 原文地址:http://channel9.msdn.com/Series/Win ...

  4. Windows Phone 8初学者开发—第20部分:录制Wav音频文件

    原文 Windows Phone 8初学者开发—第20部分:录制Wav音频文件 原文地址:http://channel9.msdn.com/Series/Windows-Phone-8-Develop ...

  5. Windows Store App JavaScript 开发:选取文件和文件夹

    前面提到过,文件打开选取器由FileOpenPicker类表示,用于选取或打开文件,而文件夹选取器由FolderPicker类表示,用来选取文件夹.在FileOpenPicker类中,pickSing ...

  6. Java开发桌面程序学习(五)——文件选择器和目录选择器的使用

    选择器的使用 DirectoryChooser目录选择器官方文档 FileChooser文件选择器官方文档 文件选择器的使用 JavaFx中有个FileChoser,可以打开一个对话框来选择文件 Fi ...

  7. 《深入浅出Windows 10通用应用开发》

        <深入浅出Windows 10通用应用开发>采用Windows 10的SDK进行重新改版,整合了<深入浅出Windows Phone 8.1应用开发>和<深入解析 ...

  8. Windows Phone 8初学者开发—第4部分:XAML简介

    原文  Windows Phone 8初学者开发—第4部分:XAML简介 原文地址: http://channel9.msdn.com/Series/Windows-Phone-8-Developme ...

  9. 课程上线 -“新手入门 : Windows Phone 8.1 开发”

    经过近1个月的准备和录制,“新手入门 : Windows Phone 8.1 开发”系列课程已经在Microsoft 虚拟学院上线,链接地址为:http://www.microsoftvirtuala ...

随机推荐

  1. 蓝桥网试题 java 基础练习 矩阵乘法

    ------------------------------------------------------------ 第一次感觉到好好学习的重要性QAQ 在做这道题之前请先学会 :矩阵乘法(百度百 ...

  2. 关于data-xxx属性大小写不敏感,不识别大写的几点总结

    1.所有标签属性,没有大小写区分,都是小写,如:data-userID,在输出后会变成data-userid,前者只能获取到'undefined'. 2.dataset 自动把 - 转换为驼峰.类似的 ...

  3. HTTP严格安全传输(HTTP Strict Transport Security, HSTS)chromuim实现源码分析(一)

    // HTTP strict transport security (HSTS) is defined in// http://tools.ietf.org/html/ietf-websec-stri ...

  4. 设置npm安装模块目录<nodejs>

    nodejs安装模块命令: npm install <input_name> # 本地安装 npm install <input_name> -g # 全局安装 1.npm i ...

  5. java 解析json

    例<解析评论> //post方式请求 String url=“http://product.dangdang.com/comment/comment.php?product_id=6056 ...

  6. Codeforces 506E Mr. Kitayuta's Gift (矩阵乘法,动态规划)

    描述: 给出一个单词,在单词中插入若干字符使其为回文串,求回文串的个数(|s|<=200,n<=10^9) 这道题超神奇,不可多得的一道好题 首先可以搞出一个dp[l][r][i]表示回文 ...

  7. groovy学习(三)range

    // 1900..1999 包含边界// 2000..<2100 不包含边界twentiethCentury = 1900..1999reverseTen = 10..1println(twen ...

  8. MongoDB【第二篇】集群搭建

    第一步:准备 1.安装包 mongodb-linux-x86_64-rhel70-3.4.2.tgz 2. 架构: 本文为 1-primary.1-secondary.1-arbiter 的 mong ...

  9. EWS 通过SubscribeToPullNotifications订阅Exchange新邮件提醒

    摘要 在ews中提供了一种拉通知的方式获取服务端邮件的操作,通过这种方式客户端可以订阅该通知,在邮箱有变化的时候,可以收到通知. 工作方式 EWS 通知是在订阅的基础上处理的.通常是一个订阅每个邮箱, ...

  10. Unbutu14.04 切换ROOT用户后无法启用音频

    系统环境: Ubuntu14.04 x64 问题描述: 今天安装了Ubuntu14.04的64位系统,启用root用户登录后,观看视频时出现没有声音的现象. 问题原因: Ubuntu安装后默认root ...