I am trying to move xml configure files from the installation directory to the local directory. When it gets to StorageFolder.GetFilesAsync() it freezes the app and never recovers.
The code I am calling is inside a Windows RT project so I can't make it async at the public method. Seems to make no difference if I make the client UWP app method an async call.
private async void InstallButton_Click(object sender, RoutedEventArgs e)
{
await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
bool installed = FileManager.Install(StorageLocation.Local);
});
}
public static bool Install(StorageLocation location)
{
return InstallAsync(location).Result;
}
private static async Task<bool> InstallAsync(StorageLocation location)
{
try
{
StorageFolder destinationFolder = null;
if (location == StorageLocation.Local)
{
destinationFolder = ApplicationData.Current.LocalFolder;
}
else if (location == StorageLocation.Roaming)
{
destinationFolder = ApplicationData.Current.RoamingFolder;
}
if (destinationFolder == null)
{
return false;
}
StorageFolder folder = Package.Current.InstalledLocation;
if (folder == null)
{
return false;
}
// Language files are installed in a sub directory
StorageFolder subfolder = await folder.GetFolderAsync(languageDirectory);
if (subfolder == null)
{
return false;
}
// Get a list of files
IReadOnlyList<StorageFile> files = await subfolder.GetFilesAsync();
foreach (StorageFile file in files)
{
if (file.Name.EndsWith(".xml"))
{
await file.CopyAsync(destinationFolder);
}
}
}
catch (Exception)
{ }
return IsInstalled(location);
}