UiPath Documentation
activities
latest
false
Important :
Veuillez noter que ce contenu a été localisé en partie à l’aide de la traduction automatique. La localisation du contenu nouvellement publié peut prendre 1 à 2 semaines avant d’être disponible.
UiPath logo, featuring letters U and I in white

Activités de productivité

Dernière mise à jour 16 avr. 2026

API d'automatisation codée Google Drive

Crée un service Google Drive.

Espace de noms: UiPath.Gsuite.Activities.API

Assembly: UiPath.Gsuite.Activities.API (in UiPath.Gsuite.Activities.API.dll)

Constructeurs

ConstructeurDescriptionSyntaxe
ServiceGoogleDriveInitialise une nouvelle instance de la classe GoogleDriveServicepublic class GoogleDriveService : IGoogleDriveService

Méthodes

NomDescription
Apply File LabelsApplique les libellés Google Drive au fichier spécifié.
Effacer les champs de libellé du fichier (Clear File Label Fields)Supprime un ou plusieurs champs de libellé d'un fichier.
Copy FileCopie un fichier dans un emplacement Google Drive spécifié.
Créer un dossier (Create Folder)Crée un dossier à l'emplacement Google Drive spécifié.
Supprimer l'élémentSupprime un fichier ou un dossier spécifié.
DeleteItemPermissionDeletes the specified permission for a file or folder.
Télécharger le fichierTélécharge le fichier spécifié.
Obtenir les libellés du Drive (Get Drive Labels)Obtient les libellés de lecteur avec des champs vides.
Get FileObtient un fichier à partir de Google Drive par chemin relatif ou par URL, ID ou chemin complet.
GetFileFolderInfoRetrieves information about a file or folder by URL, ID, or full path.
Obtenir les libellés de fichier (Get File Labels)Récupère une liste des fichiers à partir de l'emplacement Google Drive spécifié.
Get FilesRécupère une liste des fichiers à partir de l'emplacement Google Drive spécifié.
GetFilesandFoldersRécupère une liste de fichiers et de dossiers à partir de l'emplacement Google Drive spécifié.
Get FolderObtient un dossier à partir de Google Drive par chemin relatif, ou par URL, ID ou chemin complet.
Obtenir les dossiersRécupère une liste des dossiers à partir de l'emplacement Google Drive spécifié.
Obtenir un élémentObtient un fichier ou un dossier à partir de Google Drive par chemin relatif ou par URL, ID ou chemin complet.
GetItemPermissionsRetrieves the list of permissions for the specified file or folder.
Move FileDéplace un dossier vers le dossier de destination spécifié dans Google Drive.
Move FolderDéplace un dossier vers le dossier de destination spécifié dans Google Drive.
RefreshFileObtient la dernière version du fichier spécifié.
ActualiserDossierObtient la dernière version du dossier spécifié.
RefreshItemObtient la dernière version du fichier ou dossier spécifié.
RenameItemRenames a file or folder in Google Drive.
Remove File LabelsSupprime les libellés d'un fichier.
Share FilePartage un fichier avec tout le monde, avec un domaine ou avec les destinataires spécifiés.
Partager le dossierPartage un dossier avec tout le monde, avec un domaine ou avec les destinataires spécifiés.
UpdateItemPermissionUpdates the specified permission for a file or folder.
Upload FileCharge un fichier dans Google Drive
Upload FilesUploads files to Google Drive

Exemple

Dans l'exemple suivant, vous pouvez voir comment utiliser les API d'automatisation codées pour renommer tous les fichiers d'un dossier Google Drive en ajoutant un sous-fixe.

using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;

namespace GoogleWorkspaceCodedWorkflows
{
    public class Rename_all_the_files_in_a_Google_Drive_folder : CodedWorkflow
    {
        [Workflow]
        public void Execute(string NameSubfix)
        {
           var service = google.Drive(connections.Drive.<connectionID>);
            
            var folderUrl ="https://drive.google.com/drive/folders/1sE7UqjderUPv24Rxkto5jyefAuVLeVCz";
            var folder = service.GetFolder(folderUrl,IdentificationType.UrlOrId);
            var files = service.GetFiles(folder);
            foreach (var file in files)
            {
                System.Console.WriteLine(file.FullName);
                file.Move(folder,file.FullName+"-"+NameSubfix,ConflictBehavior.Replace);
                
            }
        }
    }
}
using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;

namespace GoogleWorkspaceCodedWorkflows
{
    public class Rename_all_the_files_in_a_Google_Drive_folder : CodedWorkflow
    {
        [Workflow]
        public void Execute(string NameSubfix)
        {
           var service = google.Drive(connections.Drive.<connectionID>);
            
            var folderUrl ="https://drive.google.com/drive/folders/1sE7UqjderUPv24Rxkto5jyefAuVLeVCz";
            var folder = service.GetFolder(folderUrl,IdentificationType.UrlOrId);
            var files = service.GetFiles(folder);
            foreach (var file in files)
            {
                System.Console.WriteLine(file.FullName);
                file.Move(folder,file.FullName+"-"+NameSubfix,ConflictBehavior.Replace);
                
            }
        }
    }
}

Dans l'exemple suivant, vous pouvez voir comment utiliser les API d'automatisation codées pour lire tous les fichiers d'un dossier, y compris les sous-dossiers.

using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.GSuite.Drive.Models;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;

namespace GoogleWorkspaceCodedWorkflows
{
    public class ReadAllFilesFromAFolder : CodedWorkflow
    {
        [Workflow]
        public void Execute()
        {            
            var service = google.Drive(connections.Drive.<connectionID>);     
         
            // Read All files from Google Drive and its subfolders 
            readFilesInAFolder(null,service);
            
        }
        // Read All files from a Folder including all subfolders
        public void readFilesInAFolder(IFolder? googleFolder, IGoogleDriveService service)
        {
            var filesAndFolders = service.GetFilesAndFolders(googleFolder);
        
            foreach (var fileFolder in filesAndFolders.OrderBy(f=> f.IsFolder))
            {
                if(!fileFolder.IsFolder)
                {
                    var folder = service.GetFolder(fileFolder.Item.ParentId);
                    
                    Log("Folder: "+ folder.FullName+" FileName: "+fileFolder.FullName+ " Type: "+fileFolder.Item.MimeType);
                }
                else
                {
                    readFilesInAFolder(fileFolder as IFolder, service);
                }
            }
            
        }
    }
    
}
using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.GSuite.Drive.Models;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;

namespace GoogleWorkspaceCodedWorkflows
{
    public class ReadAllFilesFromAFolder : CodedWorkflow
    {
        [Workflow]
        public void Execute()
        {            
            var service = google.Drive(connections.Drive.<connectionID>);     
         
            // Read All files from Google Drive and its subfolders 
            readFilesInAFolder(null,service);
            
        }
        // Read All files from a Folder including all subfolders
        public void readFilesInAFolder(IFolder? googleFolder, IGoogleDriveService service)
        {
            var filesAndFolders = service.GetFilesAndFolders(googleFolder);
        
            foreach (var fileFolder in filesAndFolders.OrderBy(f=> f.IsFolder))
            {
                if(!fileFolder.IsFolder)
                {
                    var folder = service.GetFolder(fileFolder.Item.ParentId);
                    
                    Log("Folder: "+ folder.FullName+" FileName: "+fileFolder.FullName+ " Type: "+fileFolder.Item.MimeType);
                }
                else
                {
                    readFilesInAFolder(fileFolder as IFolder, service);
                }
            }
            
        }
    }
    
}
  • Constructeurs
  • Méthodes
  • Exemple

Cette page vous a-t-elle été utile ?

Connecter

Besoin d'aide ? Assistance

Vous souhaitez apprendre ? UiPath Academy

Vous avez des questions ? UiPath Forum

Rester à jour