windows phone 8.1开发:文件选择器FileSavePicker
上一篇文章小梦分享了文件选择器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的更多相关文章
- windows phone 8.1开发:文件选择器FileOpenPicker
原文出自:http://www.bcmeng.com/fileopenpicker/ 今天小梦给大家分享一下 windows phone 8.1中的文件选择器,和之前的windows phone8的不 ...
- Windows Store App JavaScript 开发:文件选取器
正如前面章节C#语言中所介绍的,文件选取器是应用与系统进行交互的一个接口,通过文件选取器可以在应用中直接与文件系统进行交互,访问不同位置的文件或文件夹,或者将文件存储在指定位置.文件选取器分为对文件进 ...
- Windows Phone 8初学者开发—第21部分:永久保存Wav音频文件
原文 Windows Phone 8初学者开发—第21部分:永久保存Wav音频文件 第21部分:永久保存Wav音频文件 原文地址:http://channel9.msdn.com/Series/Win ...
- Windows Phone 8初学者开发—第20部分:录制Wav音频文件
原文 Windows Phone 8初学者开发—第20部分:录制Wav音频文件 原文地址:http://channel9.msdn.com/Series/Windows-Phone-8-Develop ...
- Windows Store App JavaScript 开发:选取文件和文件夹
前面提到过,文件打开选取器由FileOpenPicker类表示,用于选取或打开文件,而文件夹选取器由FolderPicker类表示,用来选取文件夹.在FileOpenPicker类中,pickSing ...
- Java开发桌面程序学习(五)——文件选择器和目录选择器的使用
选择器的使用 DirectoryChooser目录选择器官方文档 FileChooser文件选择器官方文档 文件选择器的使用 JavaFx中有个FileChoser,可以打开一个对话框来选择文件 Fi ...
- 《深入浅出Windows 10通用应用开发》
<深入浅出Windows 10通用应用开发>采用Windows 10的SDK进行重新改版,整合了<深入浅出Windows Phone 8.1应用开发>和<深入解析 ...
- Windows Phone 8初学者开发—第4部分:XAML简介
原文 Windows Phone 8初学者开发—第4部分:XAML简介 原文地址: http://channel9.msdn.com/Series/Windows-Phone-8-Developme ...
- 课程上线 -“新手入门 : Windows Phone 8.1 开发”
经过近1个月的准备和录制,“新手入门 : Windows Phone 8.1 开发”系列课程已经在Microsoft 虚拟学院上线,链接地址为:http://www.microsoftvirtuala ...
随机推荐
- Windows 10 IoT Serials 4 - 如何在树莓派上使用Cortana语音助手
从Windows 10 IoT Core 14986版本开始,微软已经加入Cortana语音助手功能.之前,我们只能使用本地语音识别,需要编写应用程序,下载到设备中才能实现.从现在开始,微软已经从系统 ...
- Spring集成MyBatis框架
Java在写数据库查询时,我接触过四种方式: 1.纯Java代码,引用对应的数据库驱动包,自己写连接与释放逻辑(可以用连接池) 这种模式实际上性能是非常不错的,但是使用起来并不是非常方便:一是要手工为 ...
- javascript 计算两个日期的差值
代码 Typescript版 /** * TimeSpan just like the class TimpSpan in C# ,represent the time difference * @c ...
- 02月刊(上) | 微信小程序
* { margin: 0; padding: 0 } .con { width: 802px; margin: 0 auto; text-align: center; position: inher ...
- j2se 总结
j2se在学习第二遍的时候,感觉还是比较亲切的.
- context:annotation-config, mvc:annotation-driven, context:compont-scan 区别
当我们需要使用BeanPostProcessor时,直接在Spring配置文件中定义这些Bean显得比较笨拙,例如: 使用@Autowired注解,必须事先在Spring容器中声明AutowiredA ...
- 福利:Axure 8.0 Pro 破解版下载
今天从网上找了好久Axure 8.0 Pro版本 但是都不能用了,于是自己想到了这个办法 1.从官网下单 Axure 8.0 版本 官网地址:https://www.axure.com.cn/3510 ...
- beautifulsoup 获取a(tag)的属性href
一开始使用使用attrs(“href”) 出现错误TypeError: 'dict' object is not callable 由于attrs字典类型 atrrs["href" ...
- FTP与TFTP
文件传输协议如今有了很大的广泛,他屏蔽了计算机内部的实现细节,因为可以适用于各种计算机之间文件的传输. 文件咋网络中传输其实是一件很复杂的事情,涉及的问题有很多,比如 (1)计算机存储数据的格式不同 ...
- GCD(关于容斥原理)
Problem Description Given 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD( ...