public FileInfo Invoke(string parentId, string title, string mimeType = null) { try { if (String.IsNullOrEmpty(title)) { throw new Exception("Input parameter 'title' is null or empty."); } using (DriveService driveService = DriveService.Create()) { FileInfo parentInfo = driveService.GetFile(parentId); if (parentInfo == null) { throw new Exception("Parent no longer exists."); } var insertStream = new API.DriveService.InsertStream(); insertStream.Init(parentInfo.Id, title, mimeType); insertStream.Visible = false; driveService.InsertFile(insertStream); while (!insertStream.Finished) { System.Threading.Thread.Sleep(250); } if (insertStream.Cancelled) { return(null); } if (insertStream.Failed) { throw new LogException("Insert file could not complete - " + insertStream.ExceptionMessage, true, true); } FileInfo fileInfo = insertStream.FileInfo; return(fileInfo); } } catch (Exception exception) { Log.Error(exception); return(null); } }