IPWorks Cloud 2020 C++ Edition

Questions / Feedback?

CopyFile Method

Copies a file.

Syntax

ANSI (Cross Platform)
char* CopyFile(const char* lpszFromFilePath, const char* lpszToFilePath, const char* lpszToShare);

Unicode (Windows)
LPWSTR CopyFile(LPCWSTR lpszFromFilePath, LPCWSTR lpszToFilePath, LPCWSTR lpszToShare);
- (NSString*)copyFile:(NSString*)fromFilePath :(NSString*)toFilePath :(NSString*)toShare;
#define MID_AZUREFILE_COPYFILE 7

IPWORKSCLOUD_EXTERNAL int IPWORKSCLOUD_CALL IPWorksCloud_AzureFile_Do(void *lpObj, int methid, int cparam, void *param[], int cbparam[], int64 *lpllVal);

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");
}

Error Handling (C++)

This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.

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