Reading a .xml file from a shared folder on Hololens 2

VHololenser 1 Reputation point
2022-06-06T08:52:05.757+00:00

I've been trying to access an xml file on a shared folder using the samba share methode without any succes.

I declared the right capabilities and also added 'file type association' to my Package.appxmanifest as it shows in the screenshot

<Applications>  
    <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="AppLauncherml.App">  
      <uap:VisualElements DisplayName="AppLauncherml" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="AppLauncherml" BackgroundColor="transparent">  
        <uap:DefaultTile ShortName="AppLauncher" Wide310x150Logo="Assets\Wide310x150Logo.png" />  
        <uap:SplashScreen Image="Assets\SplashScreen.png" BackgroundColor="#FFFFFF" />  
        <uap:InitialRotationPreference>  
          <uap:Rotation Preference="landscape" />  
          <uap:Rotation Preference="landscapeFlipped" />  
          <uap:Rotation Preference="portrait" />  
          <uap:Rotation Preference="portraitFlipped" />  
        </uap:InitialRotationPreference>  
      </uap:VisualElements>  
      <Extensions>  
        <uap:Extension Category="windows.fileTypeAssociation">  
          <uap:FileTypeAssociation Name="readxml">  
            <uap:SupportedFileTypes>  
              <uap:FileType ContentType="application/xml">.xml</uap:FileType>  
            </uap:SupportedFileTypes>  
            <uap:DisplayName>xmlRead</uap:DisplayName>  
            <uap:EditFlags AlwaysUnsafe="true"/>  
          </uap:FileTypeAssociation>  
        </uap:Extension>  
        <uap:Extension Category="windows.shareTarget">  
          <uap:ShareTarget Description="xml">  
            <uap:SupportedFileTypes>  
              <uap:FileType>.xml</uap:FileType>  
            </uap:SupportedFileTypes>  
            <uap:DataFormat>HTML</uap:DataFormat>  
            <uap:DataFormat>Texte</uap:DataFormat>  
          </uap:ShareTarget>  
        </uap:Extension>  
      </Extensions>  
    </Application>  
  </Applications>  
  <Capabilities>  
    <uap:Capability Name="enterpriseAuthentication" />  
    <Capability Name="internetClient" />  
    <Capability Name="internetClientServer" />  
    <Capability Name="privateNetworkClientServer" />  
    <uap2:Capability Name="spatialPerception" />  
    <DeviceCapability Name="webcam" />  
    <DeviceCapability Name="proximity" />  
    <DeviceCapability Name="microphone" />  
    <DeviceCapability Name="gazeinput" />  
  </Capabilities>  

the using Windows.Storage and Windows.Storage.Streams are writen inside of an ENABLE_WINMD_SUPPORT

using System;  
using System.IO;  
  
using System.Threading.Tasks;  
using UnityEngine.UI;  
using System.Windows;  
using System.Collections;  
using System.Collections.Generic;  
  
#if ENABLE_WINMD_SUPPORT  
using Windows.Storage;  
using Windows.Storage.Streams;  
#endif  

My shared folder accepts connexions from 'Guests' which has all the permissions and 'Everyone' which has the read capability both on my shared folder options and on the 'manage' section on 'My computer' , i followed the instruction on a microsoft guide.

here's the portion of my code responsible for reading the xml file;

public class XML : MonoBehaviour  
{  
XmlDocument XmlData = new XmlDocument();  
  
void Start()  
{          
    LoadXml(XmlData);  
}  
  
  
async public void LoadXml(XmlDocument XmlData)  
  {  
#if ENABLE_WINMD_SUPPORT  
    XmlData.PreserveWhitespace = true;  
//StorageFolder file = await Node.GetNode(@"192.168.2.18\NetworkShare\ConfigFile.xml");  
  
    StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(@"\\192.168.2.18\NetworkShare");  
  
    StorageFile file = await folder.GetFileAsync("ConfigFile.xml");    
  
    string[] BtnTexte = new string[10];  
     if (file != null)  
      {  
         //using (Stream stream = await file.OpenAsync())  
        using (Stream stream = await file.OpenStreamForReadAsync())             
    {  
  
           // XmlData = await Task.Run(() => XmlDocument.Load(stream));  
           XmlData.Load(stream);  
  
            XmlElement root = XmlData.DocumentElement;  
            XmlNodeList elemList = root.GetElementsByTagName("name");  

My aim is to read the xml file and create buttons on my Hololens project depending on the data on the xml file.

Im also doing some research on how to debug my project, as i can't use the 'attach to unity debugger' even tho i know my Hololens ip and port and the 'Debug already installed app' from my C# project doesn't trigger any of my break points.

HoloLens Development
HoloLens Development
HoloLens: A family of Microsoft self-contained, holographic devices that enable engagement with digital content and interaction with holograms in the surrounding environment.Development: The process of researching, productizing, and refining new or existing technologies.
385 questions
{count} votes