I am trying to load a file from a unity applications build for UWP, more specific for the HoloLens. I have a working FilePicker
#if !UNITY_EDITOR && UNITY_WSA_10_0
UnityEngine.WSA.Application.InvokeOnUIThread(async () =>
{
var picker = new Windows.Storage.Pickers.FileOpenPicker();
picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
picker.FileTypeFilter.Add(".bytes");
Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();
UnityEngine.WSA.Application.InvokeOnAppThread(() =>
{
string name = (file != null) ? file.Name : "No data";
string path = (file != null) ? file.Path : "No data";
if( file != null )
CaseManager.Instance.ActiveUseCase = new Case(new CaseDataDiscriptor(name, path));
SceneLoader.Instance.LoadSceneAsync("ARViewer");
SceneLoader.Instance.UnLoadScene("CaseList");
}, false);
}, false);
#endif
However, when trying to load the file in an other part of the code using
File.ReadAllBytes(filePath);
I get following exception, where is the actual file path of the file. Which exist as I picked it earlier using the file picker
DirectoryNotFoundException: Could not find a part of the path <MYPATH>.at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x00000] in <00000000000000000000000000000000>:0 at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <00000000000000000000000000000000>:0 at System.IO.File.OpenRead (System.String path) [0x00000] in <00000000000000000000000000000000>:0 at System.IO.File.ReadAllBytes (System.String path) [0x00000] in <00000000000000000000000000000000>:0 at Assets.Scripts.Utils.Parser.Parser.FileToByteArray (System.String filePath) [0x00000] in <000000000000000000000
Any help would be appreciated