Discuss this help topic in SecureBlackbox Forum
Clouds: Copy and move files
To move a file to another folder use TElGoogleDriveFile.Move() method of a file object, which you want to move. Pass an object, that identifies destination folder, as the parameter.
C#:
// get an object for the target folder
TElGoogleDriveFolder targetFolder = storage.AcquireObject(@”...”) as
TElGoogleDriveFolder;
Console.WriteLine("Target folder: {0} (id = {1})",
targetFolder.Name, targetFolder.ID);
// get an object for the file to be moved
TElGoogleDriveFile file = storage.AcquireObject(@"...") as TElGoogleDriveFile;
Console.WriteLine("File: {0} (parent = {1})", file.Name, file.ParentID);
// actually, move the file to the target folder
file.Move(targetFolder);
Console.WriteLine("Moved: {0} (parent = {1})", file.Name, file.ParentID);
// don't forget to release the objects
file.Release();
targetFolder.Release();
As Google Drive allows a file or a document to have several parent folders, there is an overload of Move() method available, that accepts an array of destination folders.
To copy a file (TElGoogleDriveFile) or a document (TElGoogleDriveDocument) to another folder, call its Copy() method and pass the destination folder to it. The method returns an object of the same type as a copied file or document is.
C#:
// get an object for the target folder
TElGoogleDriveFolder targetFolder = storage.AcquireObject(@"...") as
TElGoogleDriveFolder;
Console.WriteLine("Target folder: {0} (id: {1})",
targetFolder.Name, targetFolder.ID);
// get an object for the file to be copied
TElGoogleDriveFile file = storage.AcquireObject(@"...") as TElGoogleDriveFile;
Console.WriteLine("Original: {0} (parent: {1})", file.Name, file.Parent);
// actually, copy the file to the target folder
TElGoogleDriveFile copiedFile = file.Copy(targetFolder) as TElGoogleDriveFile;
Console.WriteLine("Copied: {0} (parent: {1})", copiedFile.Name, copiedFile.Parent);
// don't forget to release the objects
copiedFile.Release();
file.Release();
targetFolder.Release();