file picker uwp c#
C#
// Create the picker object and set options
var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
openPicker.viewMode = Windows.Storage.Pickers.PickerViewMode.thumbnail;
openPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.picturesLibrary;
// Users expect to have a filtered view of their folders depending on the scenario.
// For example, when choosing a documents folder, restrict the filetypes to documents for your application.
openPicker.fileTypeFilter.replaceAll([".png", ".jpg", ".jpeg"]);
// Open the picker for the user to pick a file
openPicker.pickSingleFileAsync().then(function (file) {
if (file) {
// Application now has read/write access to the picked file
WinJS.log && WinJS.log("Picked photo: " + file.name, "sample", "status");
} else {
// The picker was dismissed with no selected file
WinJS.log && WinJS.log("Operation cancelled.", "sample", "status");
}
});public async Task GetFile()
{
Windows.Storage.Pickers.FileOpenPicker picker = new Windows.Storage.Pickers.FileOpenPicker();
picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.List;
picker.FileTypeFilter.Add(".txt");
//Prompt the user to open the log file:
Windows.Storage.StorageFile logFile = await picker.PickSingleFileAsync();
try
{
using (var stream = await logFile.OpenStreamForReadAsync())
using (var reader = new StreamReader(stream))
{
var line = await reader.ReadLineAsync();
Debug.WriteLine($"The first line: {line} - waiting");
await Task.Delay(10000);
line = await reader.ReadLineAsync();
Debug.WriteLine($"The next line: {line} - waiting");
}
}
catch (Exception exc)
{
Debug.WriteLine($"Exception {exc.Message}");
}
}var picker = new Windows.Storage.Pickers.FileOpenPicker();
picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
picker.FileTypeFilter.Add(".jpg");
picker.FileTypeFilter.Add(".jpeg");
picker.FileTypeFilter.Add(".png");
Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();
if (file != null)
{
// Application now has read/write access to the picked file
this.textBlock.Text = "Picked photo: " + file.Name;
}
else
{
this.textBlock.Text = "Operation cancelled.";
}
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
// Application now has read/write access to the picked file
OutputTextBlock.Text = "Picked photo: " + file.Name;
}
else
{
OutputTextBlock.Text = "Operation cancelled.";
}
Also in C#:
- Title
- unity get velocity at point
- Category
- C#
- Title
- unity left mouse button
- Category
- C#
- Title
- csharp datetime string format
- Category
- C#
- Title
- initialize matrix c#
- Category
- C#
- Title
- exception handling c#
- Category
- C#
- Title
- unity if gameobject exists
- Category
- C#
- Title
- in unity i want to destroy a gameobject when it hits the edge of the screen
- Category
- C#
- Title
- c# how to run external program with args
- Category
- C#
- Title
- can send but cannot receive email dreamhost email
- Category
- C#
- Title
- get first and last item list c#
- Category
- C#
- Title
- json serialize object capitalization config
- Category
- C#
- Title
- unity how to get transform scale
- Category
- C#
- Title
- c# loop through two dimensional array
- Category
- C#
- Title
- unity coroutine
- Category
- C#
- Title
- how to see if they are aholding down a key unity
- Category
- C#
- Title
- resize image c#
- Category
- C#
- Title
- write last line txt file c#
- Category
- C#
- Title
- copy to clipboard unbity
- Category
- C#
- Title
- unity cycle children
- Category
- C#
- Title
- convert string array to int C#
- Category
- C#
- Title
- unity get all by tag
- Category
- C#
- Title
- how to stop a form c#
- Category
- C#
- Title
- c# retrieve files in folder
- Category
- C#
- Title
- rotate player unity
- Category
- C#
- Title
- c# creating exceptions
- Category
- C#
- Title
- invalidoperationexception c# ui thread
- Category
- C#
- Title
- unity rigid body variable
- Category
- C#
- Title
- unity transfoprm position y change
- Category
- C#
- Title
- c# inheritance constructor
- Category
- C#
- Title
- unity create gameobject
- Category
- C#
- Title
- C# move form without border
- Category
- C#
- Title
- c# get desktop path
- Category
- C#
- Title
- how to detected WindowCloseEvent in other window wpf
- Category
- C#
- Title
- c# remove spaces from string
- Category
- C#
- Title
- find negative version of integer in c#
- Category
- C#
- Title
- c# inline if
- Category
- C#
- Title
- c# move with arrow keys
- Category
- C#
- Title
- freeze position unity c#
- Category
- C#
- Title
- c# ramdom
- Category
- C#
- Title
- how to get the last element in an array in c#
- Category
- C#
- Title
- c# verify in class exist in list
- Category
- C#
- Title
- c# create new object
- Category
- C#
- Title
- add object to list c#
- Category
- C#
- Title
- how to clear console through script unity
- Category
- C#
- Title
- unity set object scale
- Category
- C#
- Title
- c# repeat string x times
- Category
- C#
- Title
- how to hide and show object in unity script
- Category
- C#
- Title
- how to reload app.config file at runtime in c#
- Category
- C#
- Title
- c# stop loop
- Category
- C#
- Title
- c# append to file
- Category
- C#
- Title
- c# to vb.net
- Category
- C#
- Title
- c# filter non alphanumeric characters
- Category
- C#
- Title
- c# getasync response
- Category
- C#
- Title
- query associative table ef6
- Category
- C#
- Title
- covert char[] to string C#
- Category
- C#
- Title
- no overload for 'useItemOnSceneLoad' matches delegate 'UnityAction<Scene, LoadSceneMode>'
- Category
- C#
- Title
- c# reverse list
- Category
- C#
- Title
- modal dismiss
- Category
- C#
- Title
- polling data source c# using threads
- Category
- C#
- Title
- c# tuple access
- Category
- C#
- Title
- how to compare datetime in c#
- Category
- C#
- Title
- c# windows application get current path
- Category
- C#
- Title
- unity transformer double en float
- Category
- C#
- Title
- asp.net core 3.1: cast jObject to dictionary<string,string>
- Category
- C#
- Title
- max of array C#
- Category
- C#
- Title
- c# split a string and return list
- Category
- C#
- Title
- unity set list of strings
- Category
- C#
- Title
- kill child C#
- Category
- C#
- Title
- linq c# where condition
- Category
- C#
- Title
- create line in unity
- Category
- C#
- Title
- check if network is available c#
- Category
- C#
- Title
- No context type was found in the assembly
- Category
- C#
- Title
- c# serialize
- Category
- C#
- Title
- convert double to currency c#
- Category
- C#
- Title
- json stringify c#
- Category
- C#
- Title
- unity simple fps controller
- Category
- C#
- Title
- c# print
- Category
- C#
- Title
- .net core cli
- Category
- C#
- Title
- c# push numbers to array
- Category
- C#
- Title
- list.addrange in c#
- Category
- C#
- Title
- json tiers dot in name c#
- Category
- C#
- Title
- functions unity
- Category
- C#
- Title
- c# use hashtable check if key exists
- Category
- C#
- Title
- what is using static in c#
- Category
- C#
- Title
- 2d object look at object
- Category
- C#
- Title
- take screenshot in c#
- Category
- C#
- Title
- how to flip selection in aseprite
- Category
- C#
- Title
- c# linq to select even numbers
- Category
- C#
- Title
- how to change scenes in unity
- Category
- C#
- Title
- c# substring from index to end
- Category
- C#
- Title
- c# type of generic is string
- Category
- C#
- Title
- c# change variable types
- Category
- C#
- Title
- jump script unity 2d
- Category
- C#
- Title
- what type of variable is true or false in c#
- Category
- C#
- Title
- C# get object property name
- Category
- C#
- Title
- replace double backslash with single backslash c#
- Category
- C#
- Title
- void Update
- Category
- C#
- Title
- center an image horizontally and vertically
- Category
- C#
- Title
- c sharp tryparse
- Category
- C#
- Title
- sqlite connection c#
- Category
- C#