Click here to Skip to main content
15,921,716 members
Articles / Desktop Programming / WPF
Tip/Trick

File Pickers in Windows 8

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
30 Apr 2012CPOL 14.1K   2
this will shows the File pickers in windows 8

Introduction

In this article I am going to tell about the file pickers in Windows 8 such as file open picker, file folder picker etc.

Background 

This code will helps you to know about the pickers in Windows 8 metro applications.

Using the Code

1.file Open Picker

FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.Desktop;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
openPicker.FileTypeFilter.Add(".rar");
openPicker.FileTypeFilter.Add(".txt");
StorageFile   file = await openPicker.PickSingleFileAsync();
 string  fileName=file.Name;

The above code will open the files like .jpg,.rar,.txt 

In the above code we creating the object for the fileopenpicker() and we are setting the view mode as thumbnail.

And then we are setting the default starting file location as DeskTop or you can choose it as a  

Downloads, Documents, PictureLibrary etc.

And then we are adding the filters to open the files which are in specific format like .txt, .jpg and .rar

Now the method openpicker.PickSingleFileAsync() will open the file chosen by the user

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
Interested in learning new technologies. Right now i am working on Windows Phone/Store apps development , Web APi and asp.net mvc.
for more details visit my blog www.prathapk.net

Comments and Discussions

 
QuestionGood Stuff, but... Pin
Dewey18-Jul-12 11:14
Dewey18-Jul-12 11:14 
GeneralMy vote of 4 Pin
k.vishnu vardhan1-May-12 19:07
k.vishnu vardhan1-May-12 19:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.