Search Unity

UWP open folder with file explorer

Discussion in 'Windows' started by sumpfkraut, Sep 2, 2019.

  1. sumpfkraut

    sumpfkraut

    Joined:
    Jan 18, 2013
    Posts:
    143
    Someone have a example how to do this?
    When i use "Start Debugging" in VS i get this error:
    Code (csharp):
    1. onecoreuap\shell\windows.system.launcher\lib\windows.system.launcher.cpp(1903)\Windows.System.Launcher.dll!00007FF8F6CCBA70: (caller: 00007FF875066B2A) ReturnHr(1) tid(8970) 8000000E A method was called at an unexpected time
    my code:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Threading.Tasks;
    3. #if UNITY_WSA && !UNITY_EDITOR
    4. using Windows.Storage;
    5. using Windows.System;
    6. using System;
    7. #endif
    8.  
    9. namespace MyNamespace
    10. {
    11.     public class MyClass : MonoBehaviour
    12.     {
    13. #if UNITY_WSA && !UNITY_EDITOR
    14.         async
    15. #endif
    16.         public void OpenLocalFolder(string path)
    17.         {
    18. #if UNITY_WSA && !UNITY_EDITOR
    19.             Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
    20.             await Windows.System.Launcher.LaunchFolderAsync(localFolder);
    21. #endif
    22.         }
    23.     }
    24. }
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,443
    sumpfkraut likes this.
  3. sumpfkraut

    sumpfkraut

    Joined:
    Jan 18, 2013
    Posts:
    143
    thanks... finally :)
    Code (CSharp):
    1.  
    2.         public void OpenLocalFolder()
    3.         {
    4. #if UNITY_WSA && !UNITY_EDITOR
    5.             UnityEngine.WSA.Application.InvokeOnUIThread(async() => {
    6.                 Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
    7.                 await Windows.System.Launcher.LaunchFolderAsync(localFolder);
    8.             }, false);
    9. #endif
    10.         }
     
    Last edited: Sep 4, 2019