The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
How Do we access a file from local drive in hololens
Hello,
I have a C++ holographic app and in the code I want to read a file from my local file system and extract some data from it. I am not able to use fopen()/_aceess() etc functions successfully. Is there a way I can use open() on my file?
My program is an OpenGL program and I am using Angle to convert openGl to DirectX.
In universal windows app I found out that we have to use FilePicker object and StorageClass etc in order to access the file but all examples are with xaml and my program is just c++ project and I don't want to use xaml too.
Any suggestions?
Thanks a lot.
Best Answer
-
Options
Hi gbhatt,
I have a simple example here: In the Recording Audio Demo. It's based on the UWP samples modified for Holographic api. It records sound from the HL microphone, and save it to an Audio .wav file in one of the Known folders
Here's a quick snippet of code:
KnownFolders::CameraRoll->CreateFileAsync( AUDIO_FILE_NAME, CreationCollisionOption::GenerateUniqueName )).then( [this]( StorageFile^ file ) { if (nullptr == file) { ThrowIfFailed( E_INVALIDARG ); } return file->OpenAsync( FileAccessMode::ReadWrite ); })
Note: you case use the
KnownFolders::CameraRoll->OpenFileAsync(...)To Open a file asynchronously. Also keep in mind you have to make sure you give access in your package.manifest file as well.
Dwight Goins
CAO & Founder| Independent Architect | Trainer and Consultant | Sr. Enterprise Architect
MVP | MCT | MCSD | MCPD | SharePoint TS | MS Virtual TS |Windows 8 App Store Developer | Linux Gentoo Geek | Raspberry Pi Owner | Micro .Net Developer | Kinect For Windows Device Developer
http://dgoins.wordpress.com5
Answers
Actually I am using Hololens Emulator to run my program. My understanding is that if I want to access any file in hololens It should be in OneDrive( can I do fopen() in a file stored in onedrive? ). But how to test that with the emulator. Is there a location from where I can access the file using emulator? I tried keeping file in /Appdata/local/ but fopen() returns null.
Hi gbhatt,
I have a simple example here: In the Recording Audio Demo. It's based on the UWP samples modified for Holographic api. It records sound from the HL microphone, and save it to an Audio .wav file in one of the Known folders
Here's a quick snippet of code:
Note: you case use the
KnownFolders::CameraRoll->OpenFileAsync(...)
To Open a file asynchronously. Also keep in mind you have to make sure you give access in your package.manifest file as well.
Dwight Goins
CAO & Founder| Independent Architect | Trainer and Consultant | Sr. Enterprise Architect
MVP | MCT | MCSD | MCPD | SharePoint TS | MS Virtual TS |Windows 8 App Store Developer | Linux Gentoo Geek | Raspberry Pi Owner | Micro .Net Developer | Kinect For Windows Device Developer
http://dgoins.wordpress.com