1
1
1SLY22020-06-02 18:28:19
C++ / C#
1SLY2, 2020-06-02 18:28:19

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);
            }
        }

In the debugger I see that the variable
OpenedFileContent
no value is assigned and equals it
null
.
I would be very grateful for any answer that will help

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question