65.9K
CodeProject is changing. Read more.
Home

File Pickers in Windows 8

starIconstarIconstarIconstarIconemptyStarIcon

4.00/5 (1 vote)

Apr 30, 2012

CPOL
viewsIcon

14251

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