title: Writing to Application.persistentDataPath on HoloLens 2 with Unity3D and accessing files afterward through device web portal
body: <p>I'm working on Hololens 2 application in Unity 3D. I'm trying to write a configuration file to the device and access it later via the device portal in a web browser. Within the application itself, I'm being told that the file is being written to AppData/Local/Packages/[App Name]/LocalState/[File Name].txt. However, when I go and take a look at LocalAppData/[App Name] the folder LocalState/ doesn't even exist. I suspect this has to do with an error in the Package.appxmanifest file of the VS project generated by Unity.</p>
  <p>Here is the relevant C# code I'm using to write to file:</p>
  <pre><code>   void ReadResolution()
      {
          string path = Path.Combine(Application.persistentDataPath, mResFilename);
          mExcept = $&quot;No exceptions thrown by file IO while writing to \n\&quot;{path}\&quot;.&quot;;
          if(System.IO.File.Exists(path) &amp;&amp; new FileInfo(path).Length &gt; 0)
          {
              try
              {
                  StreamReader reader = new StreamReader(path);
                  if(reader != null)
                  {
                      string content = reader.ReadToEnd();
                      string[] split = content.Split(' ');
                      mWidth = Int32.Parse(split[0]);
                      mHeight = Int32.Parse(split[1]);
                  }
              }
              catch (Exception e)
              {
                  mExcept = &quot;File Read Exception: &quot; + e.Message;
              }
          }
          else
          {
              try
              {
                  using (TextWriter writer = File.CreateText(path))
                  {
                      string line = mWidth.ToString() + &quot; &quot; + mHeight.ToString();
                      writer.WriteLine(line);
                  }
              }
              catch (Exception e)
              {
                  mExcept = &quot;File Write Exception: &quot; + e.Message;
              }
          }
          Debug.Log(mExcept);
      }
  </code></pre>
  <p>I'm using the member field mExcept to record any messages or exceptions thrown during the process. It's telling me the file is written successfully, but maybe I'm just fooling myself somehow?</p>
  <p>Here are the relevant sections from the project's Package.appxmanifest file:</p>
  <pre><code>&lt;Package xmlns:mp=&quot;http://schemas.microsoft.com/appx/2014/phone/manifest&quot; 
           xmlns:uap=&quot;http://schemas.microsoft.com/appx/manifest/uap/windows10&quot; 
           xmlns:uap2=&quot;http://schemas.microsoft.com/appx/manifest/uap/windows10/2&quot; 
           xmlns:uap3=&quot;http://schemas.microsoft.com/appx/manifest/uap/windows10/3&quot; 
           xmlns:uap4=&quot;http://schemas.microsoft.com/appx/manifest/uap/windows10/4&quot; 
           xmlns:iot=&quot;http://schemas.microsoft.com/appx/manifest/iot/windows10&quot; 
           xmlns:mobile=&quot;http://schemas.microsoft.com/appx/manifest/mobile/windows10&quot;
           xmlns:rescap=&quot;http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities&quot;
           IgnorableNamespaces=&quot;uap uap2 uap3 uap4 mp mobile iot rescap&quot; 
           xmlns=&quot;http://schemas.microsoft.com/appx/manifest/foundation/windows10&quot;&gt;
  
  .
  .
  .
  
    &lt;Capabilities&gt;
      &lt;rescap:Capability Name=&quot;broadFileSystemAccess&quot; /&gt;
      &lt;uap:Capability Name=&quot;documentsLibrary&quot; /&gt;
      &lt;Capability Name=&quot;internetClient&quot; /&gt;
      &lt;Capability Name=&quot;internetClientServer&quot; /&gt;
      &lt;Capability Name=&quot;privateNetworkClientServer&quot; /&gt;
      &lt;uap2:Capability Name=&quot;spatialPerception&quot; /&gt;
      &lt;uap3:Capability Name=&quot;remoteSystem&quot; /&gt;
      &lt;DeviceCapability Name=&quot;microphone&quot; /&gt;
      &lt;DeviceCapability Name=&quot;gazeinput&quot; /&gt;
      &lt;DeviceCapability Name=&quot;wiFiControl&quot; /&gt;
      &lt;DeviceCapability Name=&quot;webcam&quot; /&gt;
    &lt;/Capabilities&gt;
  </code></pre>
  <p>Any help is appreciated. Thanks in advance.</p>