Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

FilePicker UWP

Discussion in 'Windows' started by Timo1102, Aug 6, 2019.

  1. Timo1102

    Timo1102

    Joined:
    Jan 27, 2017
    Posts:
    3
    Hi,
    In my Game I can't open the NativeFile picker. I created a seperate Visual Studio project and followed this tutorial. The main code to open the FilePicker is:
    Code (CSharp):
    1. #if NETFX_CORE
    2.         public async void OpenFilePicker()
    3.         {
    4.             var picker = new Windows.Storage.Pickers.FileOpenPicker();
    5.             picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.List;
    6.             picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
    7.             picker.FileTypeFilter.Add(".png");
    8.  
    9.             var file = await picker.PickSingleFileAsync();
    10.             if (file != null)
    11.             {
    12.                 this.onFileSelected?.Invoke(file.Name);
    13.             }
    14.         }
    15. #endif
    16.     }
    If I build the Project and try to access the FilePicker I got the following error:
    error.png

    I hope someone could help me.
     
  2. timke

    timke

    Unity Technologies

    Joined:
    Nov 30, 2017
    Posts:
    62
  3. Timo1102

    Timo1102

    Joined:
    Jan 27, 2017
    Posts:
    3
    Thank you very much it's working now.