//initially based off the following post but fundamentally reworked in order to work with my custom pinvoke filesystem nonsense (needed to see hidden files amongst other things) //https://stackoverflow.com/a/27797685 public static async Task CopyFolderAsync(List <MonitoredFolderItem> source, StorageFolder destinationContainer, string desiredName = null) { string name = System.IO.Path.GetFileName(source[0].ParentFolderPath); StorageFolder destinationFolder = null; destinationFolder = await destinationContainer.CreateFolderAsync( desiredName ?? name, CreationCollisionOption.ReplaceExisting); foreach (var item in source) { if (item.IsDir) { string temppath = Path.Combine(item.ParentFolderPath, item.Name); List <MonitoredFolderItem> listing = PinvokeFilesystem.GetItems(temppath); await CopyFolderAsync(listing, destinationFolder); } else { string temppath = Path.Combine(item.ParentFolderPath, item.Name); StorageFile tempfile = await StorageFile.GetFileFromPathAsync(temppath); await tempfile.CopyAsync(destinationFolder, tempfile.Name, NameCollisionOption.ReplaceExisting); } } }
private async void Button_Click_1(object sender, RoutedEventArgs e) { working.Visibility = Visibility.Visible; await RecursivelyCreateDirectoryAsync(path.Text); StorageFolder storageFolder = await StorageFolder.GetFolderFromPathAsync(path.Text); var odd = PinvokeFilesystem.GetItems("O:"); await CopyFolderAsync(odd, storageFolder, "game"); await new MessageDialog("Complete").ShowAsync(); }