title: Copy existing data base (storage file) to storage folder
body: <p>In my Windows Store App I want to copy existing data base to storage folder.<br>
  My data base placed on main folder of project.</p>
  
  <p>For copy data table to storage folder I use following code (<a href="http://wp.qmatteoq.com/import-an-already-existing-sqlite-database-in-a-windows-8-application/" rel="nofollow">link to article</a>):</p>
  
  <pre><code> StorageFile databaseFile = await Package.Current.InstalledLocation.GetFileAsync("people.sqlite");
   await databaseFile.CopyAsync(ApplicationData.Current.LocalFolder);
  </code></pre>
  
  <p>And all works great in VS in debug mode.<br>
  But if I use release mode or just stop debug and open my app from Windows - it doesn't work. <br> Also no exception was thrown. App just freeze when try to call <code>CopyAsync</code>. <br> I'm sure, that my <code>databaseFile!=null</code> in release mode too.</p>
  
  <p>Also I tried to get file like this:</p>
  
  <pre><code>var uri = new Uri("ms-appx:///people.sqlite");
  var file = await StorageFile.GetFileFromApplicationUriAsync(uri);
  </code></pre>
  
  <p>But it doesn't solve my problem.</p>
  
  <p>Question: What is the right way to copy existing data base to storage folder?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Thanks guys for your answers, but I can't solve my problem(</p>
  
  <p>I use CaliburnMicro for implementation MVVM.</p>
  
  <p>On my view model when page <code>Loaded</code> I call:</p>
  
  <pre><code>private async Task PrepareDatabase()
          {
              bool isDatabaseExisting;
              var storageFolder = ApplicationData.Current.LocalFolder; ;
              try
              {
                  await storageFolder.GetFileAsync("database_name.sqlite");
                  isDatabaseExisting = true;
              }
              catch
              {
                  isDatabaseExisting = false;
              }
              if (!isDatabaseExisting)
              {
                  StorageFile databaseFile = await Package.Current.InstalledLocation.GetFileAsync("database_name.sqlite");
                  await databaseFile.CopyAsync(ApplicationData.Current.LocalFolder);
              }
          }
  </code></pre>
  
  <p>My database: <br>
  <code>Name - database_name.sqlite;</code> <br><code>Build action - Content;</code><br> <code>Copy to Output Directory - Copy always;</code></p>
  
  <p>When I start app from visual studio - all works like it should. <br>
  Then I stop debug, and run app from Windows - and it freeze, when it try to open this page.</p>