Search Unity

Problem copying my stuff from hololens to OneDrive StorageFolder.GetFolderFromPathAsync returns null

Discussion in 'VR' started by LR-Developer, Mar 8, 2018.

  1. LR-Developer

    LR-Developer

    Joined:
    May 5, 2017
    Posts:
    109
    Hello,

    I want to export multiple files from my HoloLens own unity app, stored here:

    Globals.DataPath = Windows.Storage.ApplicationData.Current.LocalCacheFolder.Path;

    to OneDrive. So I try to open a FolderPicker to get / choose the OneDrive Folder for copying my stuff into, but it always return null: See current Code, saveFolder always null. I also tried to wait and reinstalled OneDrive on HoloLens, nothing helps.

    Code (CSharp):
    1.     private async void CopyFolderAsync()
    2.     {
    3.         UnityEngine.WSA.Application.InvokeOnUIThread(async () =>
    4.         {
    5.             FolderPicker saveFolderPicker = new FolderPicker();
    6.             saveFolderPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
    7.             saveFolderPicker.FileTypeFilter.Add("*");
    8.             Globals.GuiManagerInstance.SetPopupText("Export gestartet,\nbitte warten.");
    9.             StorageFolder saveFolder = await saveFolderPicker.PickSingleFolderAsync();
    10.             if (saveFolder != null)
    11.             {
    12.                 StorageFolder sourceFolder = await StorageFolder.GetFolderFromPathAsync(Globals.DataPath);
    13.                 if (sourceFolder != null)
    14.                 {
    15.                     IReadOnlyList<StorageFile> filesInFolder = await sourceFolder.GetFilesAsync();
    16.                     foreach (StorageFile item in filesInFolder)
    17.                     {
    18.                         Debug.LogWarning("file found: " + item.DisplayName);
    19.                         StorageFile copyfile = await item.CopyAsync(saveFolder);
    20.                         //await item.CopyAndReplaceAsync(item);
    21.                     }
    22.                     if (filesInFolder.Count == 0)
    23.                     {
    24.                         Debug.LogError("Export: No files in sourceFolder");
    25.                     }
    26.                 }
    27.                 else
    28.                 {
    29.                     Debug.LogError("Export: Error getting sourceFolder");
    30.                     Globals.GuiManagerInstance.SetPopupText("Export fehlgeschlagen,\nbitte noch einmal probieren.");
    31.                 }
    32.             }
    33.             else
    34.             {
    35.                 Debug.LogError("Export: Error getting saveFolder");
    36.                 Globals.GuiManagerInstance.SetPopupText("Export fehlgeschlagen,\nbitte noch einmal probieren.");
    37.             }
    38.         }, false);      
    39.     }
    I gave my app on the HoloLens every single permission, in unity Player Settings, I use Unity 2017.3.1f1 and Visual Studio 2017 for deploy. Scripting backend is .Net, I tried various Api Level.

    Any idea what am I doing wrong?

    The FileSavePicker or FileOpenPicker seem to work and open the OneDrive app, but the FolderPicker never opens anything and always Returns null...

    Please help :)

    Thanks!