Answer the question
In order to leave comments, you need to log in
File contents not showing?
Here is the code that should:
1. Open the file and read its contents
2. Write the contents to a variable, the value of which is then assigned to the variable in the ViewModel and associated with the View
The code
public static async void OpenNewFile()
{
FileOpenPicker openFilePicker = new FileOpenPicker();
openFilePicker.ViewMode = PickerViewMode.Thumbnail;
openFilePicker.FileTypeFilter.Add(".txt");
var file = await openFilePicker.PickSingleFileAsync();
if(file != null)
{
OpenedFileContent = await FileIO.ReadTextAsync(file);
}
}
OpenedFileContentno value is assigned and equals it
null.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question