wpf:

Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.DefaultExt = ".txt";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
// Open document
string filename = dlg.FileName;
}
FileStream aFile = new FileStream(filename, FileMode.Open);
StreamReader sr = new StreamReader(aFile);

需要 using System.Windows.Documents; using System.IO;

windows app:

FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.List;
openPicker.SuggestedStartLocation = PickerLocationId.Desktop;
openPicker.FileTypeFilter.Add(".txt");
ss.file = await openPicker.PickSingleFileAsync();
string filename =ss.file.Path;
StorageFile file =ss.file;
var fl = await FileIO.ReadLinesAsync(file);

需要:

using Windows.Storage;
using Windows.Storage.Pickers;
using System.Collections;

Windows phone:

FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.List;
openPicker.SuggestedStartLocation = PickerLocationId.Desktop;
openPicker.FileTypeFilter.Add(".txt");
openPicker.PickSingleFileAndContinue();
void MainPage_Activated(CoreApplicationView sender, Windows.ApplicationModel.Activation.IActivatedEventArgs args)
{
FileOpenPickerContinuationEventArgs continueArgs = args as FileOpenPickerContinuationEventArgs;
if (continueArgs != null)
{
ss.file = continueArgs.Files[];
if (ss.file != null)
{
BlankPage1 pg1 = new BlankPage1();
ss.bl = true;
Frame.Navigate(typeof(BlankPage1));
}
else
{ }
}
}
string filename = MainPage.ss.file.Path;
StorageFile file = MainPage.ss.file;
var fl = await FileIO.ReadLinesAsync(file);

需要:

using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.ApplicationModel.Core;
using Windows.ApplicationModel.Activation;

using System.Collections;

C#三个平台上的文件选择方法的更多相关文章

  1. WebService支持多平台上传文件的实现

    WebService支持多平台上传文件的实现   要使用网站上传文件,在ASP.NET的范畴,我基本上能想到的有两类,一类是通过HTTP POST请求获得文件信息,另外一类是通过WebService或 ...

  2. 朋友封装的一个ASP.NET上传文件的方法

    朋友做了asp.net开发多年,做了这个,自我感觉封装得还不错!!! 代码如下: #region 上传文件的方法 /// <summary> /// 上传文件方法 /// </sum ...

  3. MUI上传文件的方法

    <!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...

  4. windows平台是上的sublime编辑远程linux平台上的文件

    sublime是个跨平台的强大的代码编辑工具,不多说. 想使用sublime完毕linux平台下django网站的代码编辑工作以提高效率(原来使用linux下的vim效率较低,适合编辑一些小脚本). ...

  5. 三种方式上传文件-Java

    前言:负责,因为该项目他(jetty嵌入式开始SpringMvc)实现文件上传的必要性,并拥有java文件上传这一块还没有被曝光.并 Http 更多晦涩协议.因此,这种渐进的方式来学习和实践上载文件的 ...

  6. 采用Sambaserver由win平台,linux平台上传文件

    1.构造yum [root@db /]# cd /etc/yum.repos.d/ [root@db yum.repos.d]# vi yum.repo --改动光盘挂载位置,enabled设置为启动 ...

  7. 使用jquery插件uploadify上传文件的方法与疑问

    我是学生一枚,专业也不是计算机,但又要用到很多相关技术,所以在技术基础不牢靠的情况下,硬着头皮在做.最近在做一个小项目需要上传图片,而且是需要用ajax的方式.但是利用jquery的ajax方法总会有 ...

  8. 【重要】U3D存放本地游戏存档——不同平台载入XML文件的方法——IOS MAC Android

    在PC上和IOS上读取XML文件的方式略有差别,经测试,IOS上不支持如下方法载入XML文件: XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load( ...

  9. (转)U3D不同平台载入XML文件的方法——IOS MAC Android

    自:http://www.cnblogs.com/sifenkesi/archive/2012/03/12/2391330.html 在PC上和IOS上读取XML文件的方式略有差别,经测试,IOS上不 ...

随机推荐

  1. java鼠标与键盘事件监听

    package cn.stat.p3.windowdemo; import java.awt.Button; import java.awt.FlowLayout; import java.awt.F ...

  2. 2016年的个人计划-xiangjiejie

    过去一年,开发了angularjs的wap项目,appwap社区,忙忙碌碌不停的做各种活动. 职业目标 今年,要多看书,别总是被懒癌缠身. 多学习,过去半年很少看技术文章了吧,养成定期看文章的好习惯, ...

  3. Mysql中natural join和inner join的区别

    假设有如下两个表TableA,TableB TableA TableB Column1 Column2 Column1 Column3 1 2 1 3 TableA的Column1列名和TableB的 ...

  4. PHP限制网页只能在微信内置浏览器中查看并显示

    微信现在算是火了,围绕微信开发的应用也越来越多了,前段时间,自己公司需要,用PHP写了一个微信应用,为了防止自己辛苦写成的PHP应用被盗用,于是 通过PHP做了限制,只能在微信自带的浏览器中才能打开本 ...

  5. 《python基础教程》笔记之 更加抽象

    方法.函数和特性 函数和方法的区别在于self参数,方法(绑定方法)将它们的第一个参数帮顶到所属的实例上,因此这个参数可以不必提供.可以将特性绑定到一个普通函数上,这样就不会有特殊的self参数了,换 ...

  6. iOS学习之数据请求

    GET请求----同步连接 //GET请求 同步连接 - (void)handleSynchronize:(UIBarButtonItem *)item { //GET请求 //1.创建网址字符串; ...

  7. C 带指针样式的时钟

    #include <stdio.h> #include <malloc.h>#include<graphics.h>#include<conio.h> ...

  8. iOS之UISearchBar实时显示结果

    iOS之UISearchBar实时显示结果     UISearchBar 经常是配合UITableView 一起使用的,一般都将UITableView的tableHeaderView属性设置为UIS ...

  9. 这样就算会了PHP么?-1

    公司有用到这些业务,多了解一下总是没错的. 现在开始一系列的PHP学习啦... <?php $boo=true; if($boo==true) echo '变量$boo为真!'; else ec ...

  10. Codeforces 219D Choosing Capital for Treeland

    http://codeforces.com/problemset/problem/219/D 题目大意: 给出一棵树,但是它的边是有向边,选择一个城市,问最少调整多少条边的方向能使一个选中城市可以到达 ...