aqFileSystem.GetFileDrive Method

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

Use the GetFileDrive method to extract the drive part from the specified full path.

Declaration

aqFileSystem.GetFileDrive(PathToFile)

PathToFile [in]    Required    String    
Result String

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

PathToFile

Specifies the path to be processed.

Result Value

A string that holds the drive part.

Example

The code below gets the letter of the drive the specified file is located on.

JavaScript, JScript

function GetFileDriveExample()
{

  // Specifies the path to the desired file
  var sPath = "C:\\MyFiles\\MyFolder\\FileName.txt";
  
  // Obtains information about the drive the file is located on
  var sDrive = aqFileSystem.GetFileDrive(sPath);
  
  // Posts the drive letter to the test log
  Log.Message("The drive is " + sDrive);
  
}

Python

def GetFileDriveExample():
  # Specifies the path to the desired file
  sPath = "C:\\MyFiles\\MyFolder\\FileName.txt"
  
  # Obtains information about the drive the file is located on 
  sDrive = aqFileSystem.GetFileDrive(sPath)
  
  # Posts the drive letter to the test log
  Log.Message("The drive is " + sDrive)

VBScript

Sub GetFileDriveExample

  ' Specifies the path to the desired file
  sPath = "C:\MyFiles\MyFolder\FileName.txt"
  
  ' Obtains information about the drive the file is located on
  sDrive = aqFileSystem.GetFileDrive(sPath)
  
  ' Posts the drive letter to the test log
  Log.Message("The drive is " + sDrive)
  
End Sub

DelphiScript

function GetFileDriveExample;
var sPath, sDrive;
begin

  // Specifies the path to the desired file
  sPath := 'C:\MyFiles\MyFolder\FileName.txt';
  
  // Obtains information about the drive the file is located on
  sDrive := aqFileSystem.GetFileDrive(sPath);
  
  // Posts the drive letter to the test log
  Log.Message('The drive is ' + sDrive);
  
end;

C++Script, C#Script

function GetFileDriveExample()
{

  // Specifies the path to the desired file
  var sPath = "C:\\MyFiles\\MyFolder\\FileName.txt";
  
  // Obtains information about the drive the file is located on
  var sDrive = aqFileSystem["GetFileDrive"]( sPath );
  
  // Posts the drive letter to the test log
  Log["Message"]( "The drive is " + sDrive );
  
}

See Also

Working With Files From Scripts
GetFileName Method
GetFileExtension Method
GetFileFolder Method

Highlight search results