如何从另一种方法访问 StorageFile

How to access StorageFile from another method

所以我制作了一个 windows 商店应用程序,你 select 通过文件选择器用一个按钮创建一个文件,然后用另一个按钮处理该文件,但我无法获得 select将文件编辑为处理方法。
由于选择器将我的文本块之一设置为要为我尝试使用的用户显示的文件路径:
StorageFile file = await StorageFile.GetFileFromPathAsync(fullFilePath.Text);
但由于 Windows RT 限制,我只能从大多数位置拒绝访问它
关于尝试什么的任何其他建议?

第一次点击按钮:

private async Task getFile()
        {
            FileOpenPicker openPicker = new FileOpenPicker();
            openPicker.ViewMode = PickerViewMode.List;
            openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            openPicker.FileTypeFilter.Add(".txt");

            StorageFile file = await openPicker.PickSingleFileAsync();
            if (file != null)
            {
                fullFilePath.Text = file.Path;
            }
            else
            {
                updateStatus("File Selection cancelled.");
            }
        }

第二个按钮启动这个但需要使用上面的文件

private async Task processFile()
{
    ...
    string content = await FileIO.ReadTextAsync(file);
    ...
}

StorageFile 设为 class 中的一个字段:

class MyClass
{
  StorageFile m_pickedFile;

  async Task GetFile()
  {
    // Setup the picker...
    m_pickedFile = await openPicker.PickSingleFileAsync();

    // Show the path to the user...
  }

  async Task ProcessFile()
  {
    if (m_pickedFile != null)
    {
      // now use m_pickedFile...
    }
  }
}