IPWorks Cloud 2020 Delphi Edition

Questions / Feedback?

CopyFile Method

Copies a file.

function CopyFile(FromFilePath: String; ToFilePath: String; ToShare: String): String;

Remarks

This method copies the file at FromFilePath (in the share currently selected by Share) to the path ToFilePath in the share ToShare. If this method finishes successfully, it will either return an asynchronous copy operation Id, or an empty string (if the copy has finished already).

If ToShare is empty, the current value of Share will be used instead. If ToShare is non-empty, the value will automatically be lowercased when preparing the request.

Any parent folders included in ToFilePath must already exist.

If the destination file already exists, it will be overwritten.

As long as the server doesn't return an error, this method will always populate the CopyId and CopyStatus configuration settings (and clear CopyProgress and CopyStatusDesc).

Asynchronous Copy Notes

As mentioned, this method will return a copy operation Id if the copy operation was started asynchronously. In this case, use the GetFileInfo method to poll the destination file's information, which will cause the CopyStatus, CopyStatusDesc, and CopyProgress configuration settings to be refreshed.

A copy operation whose CopyStatus is still pending may also be aborted by passing the copy operation Id returned by this method (or later retrieved from CopyId) to the AbortCopy method.

// Copy a file to another location within the same share.
string copyResult = azurefile.CopyFile("/folder1/important.zip", "/folder2/secrets.zip", "");

// If the returned value *isn't* empty string, then we'll monitor the status of the
// asynchronous copy operation by polling once every 2 seconds using GetFileInfo().
if (!string.IsNullOrEmpty(copyResult)) {
  do {
    azurefile.GetFileInfo("/folder2/secrets.zip");
    Console.WriteLine("Copy progress: " + azurefile.Config("CopyProgress"));
  } while (azurefile.Config("CopyStatus") == "pending");
}

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Cloud 2020 Delphi Edition - Version 20.0 [Build 8265]