Basically the following code copies an entire folder from the app installation into the LocalCacheFolder so they can be manipulated/updated. In this case the contents of the folder called 'Data'
This code works fine on mobile, desktop and on Xbox in Dev Mode, but this line fails on Xbox in Retail Mode:
await file.CopyAsync(destinationFolder, file.Name, NameCollisionOption.FailIfExists);
This is also on a fresh install so I know the file(s) don't already exist.
Is there a different way to achieve this in Retail Mode, although in theory all UWP code should work across devices.
private async Task setupdatabase()
{
StorageFolder destinationContainer = Windows.Storage.ApplicationData.Current.LocalCacheFolder;
string root = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;
string path = root + @"\Data";
StorageFolder sfolder = await StorageFolder.GetFolderFromPathAsync(path);
await CopyFolderAsync(sfolder, destinationContainer);
}
public static async Task CopyFolderAsync(StorageFolder source, StorageFolder destinationContainer, string desiredName = null)
{
StorageFolder destinationFolder = null;
destinationFolder = await destinationContainer.CreateFolderAsync(desiredName ?? source.Name, CreationCollisionOption.OpenIfExists);
foreach (var file in await source.GetFilesAsync())
{
await file.CopyAsync(destinationFolder, file.Name, NameCollisionOption.FailIfExists);
}
foreach (var folder in await source.GetFoldersAsync())
{
await CopyFolderAsync(folder, destinationFolder);
}
}