title: Windows Run Time GetFileFromPathAsync Not Returning
body: <p>I am hoping someone can shed some light on a problem I am having. I am writing a Windows Store app which on startup needs to copy a "seed" database from the App installation folder <code>Windows.ApplicationModel.Package.Current.InstalledLocation.Path</code> to the Local data folder <code>Windows.Storage.ApplicationData.Current.LocalFolder</code>. To do this I have used the following called from my <code>OnNavigatedTo</code> method in <code>Main()</code>. </p>
  
  <pre class="lang-cs prettyprint-override"><code>protected override void OnNavigatedTo(NavigationEventArgs e)
  {
      //Calls  method in Dal Class which ensures database is in correct location and if not copies it
      Dal.LoadData();  
  
      RefreshScenarioList();
      ScenarioList.SelectedIndex = 0;  //this is the Default Item             
  }
  
  public static async void LoadData()
  {
      await CopyIfNotExists(dbName);
  }
  
  private static async Task CopyIfNotExists(string dbName)
  {
      if (await GetIfFileExistsAsync(dbName) == null)
      {
  
          StorageFile seedFile = await StorageFile.GetFileFromPathAsync(
          Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path,
          dbName));
  
          await seedFile.CopyAsync(Windows.Storage.ApplicationData.Current.LocalFolder);
      }
  }
  
  private static async Task&lt;StorageFile&gt; GetIfFileExistsAsync(string key)
  {
      try
      {
          return await ApplicationData.Current.LocalFolder.GetFileAsync(key);
  
      }
      catch (FileNotFoundException) { return default(StorageFile); }
  }
  </code></pre>
  
  <p>Please also note that I have also used <code>GetFileAsync</code> and also tried using a uri to obtain the seed file (to see if there was any difference). With the combination here I seem to be having the highest success rate. This seems to work 2-3 times out of every 4 tries but I would be much more comfortable with something that works 100% of the time. It only needs to copy the database once on startup.</p>
  
  <p>When it doesn't work it "seems" to never return (ie <code>CopyIfNotExists</code> never seems to complete). The issue appears to be in the <code>CopyIfNotExists</code> method. The problem is that virtually the next line of code in my <code>OnNavigatedTo</code> method is a query on the database and it falls over when the database doesn't copy.</p>
  
  <p>Any insights that anyone may have would be greatly appreciated.</p>