title: Unable to read file in Hololens
body: <p>I am working on an app which needs to read .obj format files in the hololens at runtime.</p>
  
  <p>Precisely, What I want to do is to save the .obj file in the hololens, when the app runs, it should access the file through the hololens file system. Putting the file in asset folder and loading by Unity editor is not what I want.</p>
  
  <p>I have searched several forums and topic threads, many give quite similar solutions. I follow some sample codes and write my own codes to read files in hololens. However, it doesn't work.</p>
  
  <p>The relevant parts of my program are as follows:</p>
  
  <p>At the head of script file, import namespace</p>
  
  <pre><code>    #if WINDOWS_UWP
      using Windows.Storage;
      using Windows.Storage.Pickers;
      using System.Threading.Tasks;
      #endif
  </code></pre>
  
  <p>The script which load obj file receives Stream type parameter. So I implement this function "OpenFileForRead", which receives a folder path and a file name as parameter, returns file stream.</p>
  
  <pre><code>    private static Stream OpenFileForRead(string folderName, string fileName)
      {
          Stream stream = null;
  #if WINDOWS_UWP
          Task task = new Task(
          async () =&gt; {
              StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(folderName);
              StorageFile file = await folder.GetFileAsync(fileName);
              stream = await file.OpenStreamForReadAsync();
          });
          task.Start();
          task.Wait();
  #endif
          return stream;
      }
  </code></pre>
  
  <p>And I call this function as follows:</p>
  
  <pre><code>#if WINDOWS_UWP
          string objname = "Model.obj";
          Stream stream = OpenFileForRead(ApplicationData.Current.RoamingFolder.Path, objname);
          loadedObj = new OBJLoader().Load(stream);
  #endif
  </code></pre>
  
  <p>"ApplicationData.Current.RoamingFolder.Path" is mapped to "LocalAppData\SOMEAPP\RoamingState" in the hololens. </p>
  
  <p>So when I deployed this app in hololens, I will upload the "Model.obj" file in device portal, to this app's RoamingState folder. Then I run this app, under ideal circumstance, it should work, unfortunately it doesn't.</p>
  
  <p>The current situation is, the app can be successfully deployed to hololens and run. Other Gameobjects can function normally in hololens, though it fails to load the .obj file into scene.</p>
  
  <p>By the way, " new OBJLoader().Load(stream); " has been tested in Unity Editor, which can successfully read and load .obj file in local folder on my PC. So it is most likely that the problem lies in the way I read files in hololens. But I surely follows the solutions given by other similar topics. I am confused and have no idea what exactly is going wrong?</p>
  
  <p>Here are some websites I have referenced and copied some codes from:</p>
  
  <p><a href="https://longqian.me/2017/02/08/hololens-file-transfer/" rel="nofollow noreferrer">https://longqian.me/2017/02/08/hololens-file-transfer/</a></p>
  
  <p><a href="https://forums.hololens.com/discussion/1862/how-to-deploy-and-read-data-file-with-app" rel="nofollow noreferrer">https://forums.hololens.com/discussion/1862/how-to-deploy-and-read-data-file-with-app</a></p>
  
  <p><a href="https://github.com/Maximilian-Winter/ObjHololensViewer" rel="nofollow noreferrer">https://github.com/Maximilian-Winter/ObjHololensViewer</a></p>
  
  <p><a href="https://github.com/jmher019/Hololens-OBJRenderer" rel="nofollow noreferrer">https://github.com/jmher019/Hololens-OBJRenderer</a></p>
  
  <p>Nearly all above use similar codes to read files in hololens, though I can't get it through on my device, it is so frustrating!</p>
  
  <p>Untiy Editor: 2018.4.0f1</p>
  
  <p>Hololens: 1st gen</p>