File Selection method on C # three platforms

Source: Internet
Author: User

Wpf:

New".txt"; Nullable<bool> result = dlg. ShowDialog (); if true ) {       //       string filename = dlg. FileName;}    
New FileStream (filename, filemode.open);             New StreamReader (Afile);

A using System.Windows.Documents is required; Using System.IO;

Windows app:

New= pickerviewmode.list;
= Pickerlocationid.desktop;
OPENPICKER.FILETYPEFILTER.ADD (".txt"await Openpicker.picksinglefileasync ();
string filename ==ss.file;
var await Fileio.readlinesasync (file);

Need:

Using Windows.storage;
Using Windows.Storage.Pickers;
Using System.Collections;

Windows Phone:

New== pickerlocationid.desktop;openpicker.filetypefilter.add (".txt  "); Openpicker.picksinglefileandcontinue ();
voidmainpage_activated (coreapplicationview sender, Windows.ApplicationModel.Activation.IActivatedEventArgs args) { Fileopenpickercontinuationeventargs Continueargs= args asFileopenpickercontinuationeventargs; if(Continueargs! =NULL) {Ss.file= continueargs.files[0]; if(Ss.file! =NULL) {BlankPage1 pg1=NewBlankPage1 (); SS.BL=true; Frame.navigate (typeof(BlankPage1)); }                Else                {                }            }}
string filename == MainPage.ss.file; var await Fileio.readlinesasync (file);

Need:


Using Windows.storage;
Using Windows.Storage.Pickers;
Using Windows.ApplicationModel.Core;
Using Windows.ApplicationModel.Activation;

Using System.Collections;

File Selection method on C # three platforms

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.