public List <string> Invoke(string parentId, List <string> fileIds) { try { using (DriveService driveService = DriveService.Create()) { FileInfo parent = driveService.GetFile(parentId); if (parent == null) { throw new Exception("Parent no longer exists."); } var copyStreams = new List <DriveProxy.API.DriveService.CopyStream>(); foreach (string fileId in fileIds) { FileInfo fileInfo = driveService.GetFile(fileId); if (fileInfo == null) { throw new Exception("File no longer exists."); } var copyStream = new DriveProxy.API.DriveService.CopyStream(); copyStream.Init(parent.Id, fileInfo); copyStreams.Add(copyStream); } driveService.CopyFiles(copyStreams); while (true) { bool finished = true; for (int i = 0; i < copyStreams.Count; i++) { DriveProxy.API.DriveService.CopyStream copyStream = copyStreams[i]; if (!copyStream.Finished) { finished = false; break; } } if (finished) { break; } System.Threading.Thread.Sleep(250); } var copiedFileIds = new List <string>(); foreach (DriveService.CopyStream copyStream in copyStreams) { if (copyStream.Completed) { copiedFileIds.Add(copyStream.FileId); } else if (copyStream.Cancelled) { } else if (copyStream.Failed) { throw new LogException("Copy could not complete - " + copyStream.ExceptionMessage, true, true); } } return(copiedFileIds); } } catch (Exception exception) { Log.Error(exception); return(null); } }