Search Unity

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

Discussion in 'Scripting' started by Wbholo, Jun 6, 2022.

  1. Wbholo

    Wbholo

    Joined:
    Oct 4, 2021
    Posts:
    2
    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



    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.
     
    Last edited: Jun 6, 2022