title: Different app behaviour when deployed locally and from Store
body: <p>I'm encountering strange issue when app is deployed from Windows Store (beta version). The app is written as Windows Phone 8.1 RunTime.</p>
  
  <p>I've a small windows runtime component written in C++/C# which checks for file existence:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>bool FileEx::FileExists(String^ path)
  {
      std::wstring pathW(path-&gt;Begin());
      std::string myPath(pathW.begin(), pathW.end());
      FILE *file = NULL;
      if (fopen_s(&amp;file, myPath.c_str(), "r") == 0)
      {
           fclose(file);
           return true;
      }
      else return false;
  }
  </code></pre>
  
  <h2>TESTING METHOD:</h2>
  
  <p>Now let's test it with two files - one created in local folder and one in folder in MusicLibrary. Everything is done in main project, which has a reference to WRC with above method in C++/C#.</p>
  
  <pre class="lang-cs prettyprint-override"><code>const string localFileName = "local.txt";
  const string musicFileName = "music.txt";
  StorageFolder localFolder = ApplicationData.Current.LocalFolder;
  StorageFolder musicFolder = await KnownFolders.MusicLibrary.CreateFolderAsync("MyFolder", CreationCollisionOption.OpenIfExists);
  await localFolder.CreateFileAsync(localFileName, CreationCollisionOption.ReplaceExisting); // create local file
  await musicFolder.CreateFileAsync(musicFileName, CreationCollisionOption.ReplaceExisting); // create file in MusicLibrary
  </code></pre>
  
  <p>a) Local file 
  Fist - test with pure C#:</p>
  
  <pre class="lang-cs prettyprint-override"><code>// First check with C# if file exists - LOCAL FILE
  StorageFile checkFile = null;
  try { checkFile = await localFolder.GetFileAsync(localFileName); }
  catch { checkFile = null; }
  if (checkFile != null) await Trace.WriteLineAsync(false, "File exists with path = {0}", checkFile.Path);
  else await Trace.WriteLineAsync(false, "File doesn't exist with path = {0}", checkFile.Path);
  </code></pre>
  
  <p>Second with written component:</p>
  
  <pre class="lang-cs prettyprint-override"><code>Exception exc = null;
  bool check = false;
  try
  {
      string path = string.Format(@"{0}\{1}", localFolder.Path, localFileName);
      await Trace.WriteLineAsync(false, "Attempt with WRC path = {0}", path);
      check = FileEx.FileExists(path);
  }
  catch (Exception ex) { exc = ex; }
  if (exc != null) await Trace.WriteLineAsync(false, "Exception WRC");
  else await Trace.WriteLineAsync(false, "No exception WRC, file exists = {0}", check);
  </code></pre>
  
  <p>b) The same with file in music library folder:</p>
  
  <p>Fist - test with pure C#:</p>
  
  <pre class="lang-cs prettyprint-override"><code>checkFile = null;
  try { checkFile = await musicFolder.GetFileAsync(musicFileName); }
  catch { checkFile = null; }
  if (checkFile != null) await Trace.WriteLineAsync(false, "File exists with path = {0}", checkFile.Path);
  else await Trace.WriteLineAsync(false, "File doesn't exist with path = {0}", checkFile.Path);
  </code></pre>
  
  <p>Second with written component:</p>
  
  <pre class="lang-cs prettyprint-override"><code>check = false;
  exc = null;
  try
  {
     string path = string.Format(@"{0}\{1}", musicFolder.Path, musicFileName);
     await Trace.WriteLineAsync(false, "Attempt with WRC path = {0}", path);
     check = FileEx.FileExists(path);
  }
  catch (Exception ex) { exc = ex; }
  if (exc != null) await Trace.WriteLineAsync(false, "Exception WRC");
  else await Trace.WriteLineAsync(false, "No exception WRC, file exists = {0}", check);
  </code></pre>
  
  <h2>RESULTS:</h2>
  
  <p>There is no exception in any case, as pure C# methods show, both files exists after their creation. As you can see in the pictures attached below, when app is deployed via Visual Studio, it works properly, runtime component shows both files, but when app is download from store, the situation is different - the WRC method works for local files, but not for these in MusicLibrary.</p>
  
  <p><img src="https://i.stack.imgur.com/7excw.jpg" alt="local deployment"></p>
  
  <p><img src="https://i.stack.imgur.com/CZjPZ.jpg" alt="store deployment"></p>
  
  <h2>QUESTION:</h2>
  
  <p>In both cases file paths are the same, in both deployments runtime component works, hence the first file exists. It seems like windows runtime component doesn't have access to MusicLibrary, despite all necessary capabilities being set in <em>packageappx.manifest</em> file (local deployment works).</p>
  
  <p>Does anyone have an idea why the windows runtime component doesn't have access to a file in MusicLibrary?
  Does windows runtime component need some additional capabilities?<BR>
  Any way to make it work?</p>