Hello everyone.

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 to upload files to hololens programmatically?

I know the Device Portal have a File Explorer tool for uploading files to specified folders.

Now I would like to make a tool, which can automatically do this work for me, is there any way?
I have look up the whole document of the Device Portal API reference for HoloLens, but it seems that there's no File Explorer API.

Best Answers

Answers

  • Hi.
    Is this working for uploading some files I need to my HoloLens ? instead of getting "Failed to upload file. Error:[object Object]"

  • @obmar45

    I am trying to use your code to upload a file to HoloLens but I don't get it working...
    Can you tell me what is written in your using block or post the whole code?
    You would help me a lot.

  • @sebben said:
    @obmar45

    I am trying to use your code to upload a file to HoloLens but I don't get it working...
    Can you tell me what is written in your using block or post the whole code?
    You would help me a lot.

    Maybe you should install the "Open source C# wrapper for Windows Device Portal REST API" first , and comprehend my codes, some params need to be replaced by your own.

  • george_hgeorge_h
    edited June 2017

    @obmar45 I followed all the steps in setting up the WindowsDevicePortal wrapper API and managed to connect to my Hololens, check IP status, etc. However, I get an exception thrown when I try to send a simple text file to it using the following code:

    void UploadSrcFile()
            {
                Task uploadTask = new Task(
                async () =>
                {
                    string filePath = "test.txt";
    
                    await portal.UploadFileAsync("Documents", filePath);
                });
                uploadTask.Start();
            }
    

    Note that I'm just building on the existing UWP sample in the library.
    The file test.txt is located in the same directory as my application .exe, but these exceptions are thrown when I try to upload it:

    Exception thrown: 'System.NotSupportedException' in System.Runtime.WindowsRuntime.dll
    Exception thrown: 'System.NotSupportedException' in System.Private.CoreLib.dll
    Exception thrown: 'System.NotSupportedException' in System.Private.CoreLib.dll
    Exception thrown: 'System.NotSupportedException' in System.Private.CoreLib.dll
    Exception thrown: 'System.NotSupportedException' in System.Private.CoreLib.dll
    Exception thrown: 'System.NotSupportedException' in System.Private.CoreLib.dll
    An exception of type 'System.NotSupportedException' occurred in System.Private.CoreLib.dll but was not handled in user code
    Additional information: NotSupported_CloningNotSupported, GetInputStreamAt

    Did you encounter these at all?

  • Never mind - just got it! Switched to the non-UWP version and everything just worked. I think it has something to do with how untrusted certificates are processed in either one.

  • I tried it UploadFileAsync method, but always throw this exception "This IRandomAccessStream does not support the GetInputStream method because it requires cloning and this stream does not support cloning."

    What could be the problem?

    Here is my code

    public async Task SaveFiles(string userName, string password, string url, string filePath)
    {
    try
    {
    DevicePortal portal = new DevicePortal(new DefaultDevicePortalConnection(url, userName, password));
    await portal.ConnectAsync();

                await portal.UploadFileAsync("LocalAppData", filePath, "LocalState", "4ab51c0b-cfe9-4548-a3b0-ca8db55bbfd2_1.0.0.0_x86__3ygapy8kah9j6");
    
                return true;
            }
            catch (COMException)
            {
                return false;
            }
        }
    
  • The HoloLens Companion v2 released on GitHub and renamed to Windows Mixed Reality Commander

    This has functionality to load apps into HoloLens or the Emulator and you can use the source code for your app

Sign In or Register to comment.