Rename Method

Applies to TestComplete 15.10, last modified on December 15, 2021

Description

Use the Rename method to change the name of the folder to which the aqFolderInfoObj object relates.

Declaration

aqFolderInfoObj.Rename(NewPath)

aqFolderInfoObj An expression, variable or parameter that specifies a reference to an aqFolderInfo object
NewPath [in]    Required    String    
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

NewPath

Specifies a new path to the folder. Both fully-qualified and relative paths are acceptable.

Result Value

True if the folder was renamed successfully, and False otherwise.

Remarks

If the method fails to rename the folder, TestComplete will post an information message to the test log explaining the cause of the failure.

Example

The code below renames the C:\MyFiles folder to C:\Work.

JavaScript, JScript

function RenameFolderExample()
{

    // Obtains information about the folder
    var FolInfo = aqFileSystem.GetFolderInfo("C:\\MyFiles");
    
    // Specifies a new folder name
    var sPath = "C:\\Work";
    
    // Renames the folder
    FolInfo.Rename(sPath);
    
}

Python

def RenameFolderExample():
  # Obtains information about the folder
  FolInfo = aqFileSystem.GetFolderInfo("C:\\MyFiles")
  # Specifies a new folder name
  sPath = "C:\\Work"
  # Renames the folder 
  FolInfo.Rename(sPath)

VBScript

Sub RenameFolderExample

    ' Obtains information about the folder
    Set FolInfo = aqFileSystem.GetFolderInfo("C:\MyFiles")
    
    ' Specifies a new folder name
    sPath = "C:\Work"
    
    ' Renames the folder
    FolInfo.Rename(sPath)
    
End Sub

DelphiScript

function RenameFolderExample;
var FolInfo, sPath;
begin

    // Obtains information about the folder
    FolInfo := aqFileSystem.GetFolderInfo('C:\MyFiles');
    
    // Specifies a new folder name
    sPath := 'C:\Work';
    
    // Renames the folder
    FolInfo.Rename(sPath);
    
end;

C++Script, C#Script

function RenameFolderExample()
{

    // Obtains information about the folder
    var FolInfo = aqFileSystem["GetFolderInfo"]( "C:\\MyFiles" );
    
    // Specifies a new folder name
    var sPath = "C:\\Work";
    
    // Renames the folder
    FolInfo["Rename"]( sPath );
    
}

See Also

Working With Files From Scripts
Copy Method
Move Method

Highlight search results