Q:

Copy file into install directory of metro-style-app

Is there a way to copy a file (selected with filepicker) to the installdir of the currently running metro style app? I tried to get the InstallationFolder with:
Windows.ApplicationModel.Package package = Windows.ApplicationModel.Package.Current;
Windows.Storage.StorageFolder installedLocation = package.InstalledLocation;

But I always get the following error while getting InstalledLocation:
Error HRESULT E_FAIL has been returned from a call to a COM component.
Is this maybe a problem with debugging the app/ not installing it from store? How to fix this exception?
The copy of the file should be possible with Windows.Storage.CopyAsync(IStroageFolder, ...). InstalledLocation is from type StorageFolder. Does somebody have some experience if it is allowed or will I get sth. like a security exception?

A:

InstalledLocation is read-only, but you can write to application's data storage folder (ApplicationData.Current.LocalFolder).
This works:
var fop = new FileOpenPicker();
fop.FileTypeFilter.Add(".txt");
StorageFile file = await fop.PickSingleFileAsync();
if (file != null)
    await file.CopyAsync(ApplicationData.Current.LocalFolder);

It might also be necessary to check library access capabilities in your application manifest.

