Exemple #1
0
        public string MoveFiles(String fileId, String folderId)
        {
            Google.Apis.Drive.v3.DriveService service = GetService();

            // Retrieve the existing parents to remove
            Google.Apis.Drive.v3.FilesResource.GetRequest getRequest = service.Files.Get(fileId);
            getRequest.Fields = "parents";
            Google.Apis.Drive.v3.Data.File file = getRequest.Execute();
            string previousParents = String.Join(",", file.Parents);

            // Move the file to the new folder
            Google.Apis.Drive.v3.FilesResource.UpdateRequest updateRequest = service.Files.Update(new Google.Apis.Drive.v3.Data.File(), fileId);
            updateRequest.Fields        = "id, parents";
            updateRequest.AddParents    = folderId;
            updateRequest.RemoveParents = previousParents;

            file = updateRequest.Execute();
            if (file != null)
            {
                return("Success");
            }
            else
            {
                return("Fail");
            }
        }
 public void Move(string fileId, string folderID, string prevFolderId)
 {
     Google.Apis.Drive.v3.FilesResource.UpdateRequest updateRequest = service.Files.Update(new Google.Apis.Drive.v3.Data.File(), fileId);
     updateRequest.Fields        = "id, parents";
     updateRequest.AddParents    = folderID;
     updateRequest.RemoveParents = prevFolderId;
     updateRequest.Execute();
 }
Exemple #3
0
        /// <summary>
        /// Realiza copy/paste de un archivo hacia otro directorio
        /// </summary>
        /// <param name="fileId"></param>
        /// <param name="folderId"></param>
        /// <returns></returns>
        public static string CopyFiles(String fileId, String folderId)
        {
            // Retrieve the existing parents to remove
            Google.Apis.Drive.v3.FilesResource.GetRequest getRequest = service.Files.Get(fileId);
            getRequest.Fields = "parents";
            Google.Apis.Drive.v3.Data.File file = getRequest.Execute();

            // Copy the file to the new folder
            Google.Apis.Drive.v3.FilesResource.UpdateRequest updateRequest = service.Files.Update(new Google.Apis.Drive.v3.Data.File(), fileId);
            updateRequest.Fields     = "id, parents";
            updateRequest.AddParents = folderId;
            file = updateRequest.Execute();
            if (file != null)
            {
                return("Success");
            }
            else
            {
                return("Fail");
            }
        }
Exemple #4
0
        public async Task <int> MoveFile(string fileId, string FolderId)
        {
            Google.Apis.Drive.v3.FilesResource.GetRequest getRequest = service.Files.Get(fileId);
            getRequest.Fields = "parents";
            Google.Apis.Drive.v3.Data.File file = getRequest.Execute();
            string previousParents = string.Join(",", file.Parents);

            Google.Apis.Drive.v3.FilesResource.UpdateRequest updateRequest = service.Files.Update(new Google.Apis.Drive.v3.Data.File(), fileId);
            updateRequest.Fields        = "parents";
            updateRequest.AddParents    = FolderId;
            updateRequest.RemoveParents = previousParents;

            file = updateRequest.Execute();

            if (file != null)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }