aqFileSystem.GetFileFolder Method

Applies to TestComplete 15.0, last modified on November 17, 2021

Description

Use the GetFileFolder method to extract the drive and folder parts from the specified full path.

Declaration

aqFileSystem.GetFileFolder(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 and folder parts of the specified file path.

Example

The code below extracts the folder path from the specified fully qualified file name and posts it to the test log.

JavaScript, JScript

function FileFolderExample()
{

  // Specifies the path to the desired file
  var sPath = "C:\\MyFiles\\MyFolder\\FileName.txt";
  
  // Obtains the path to the folder containing the file
  var sFolder = aqFileSystem.GetFileFolder(sPath);
  
  // Posts the folder path to the test log
  Log.Message(sFolder);
  
}
 
/*
The routine produces the following output

C:\MyFiles\MyFolder\
*/


Python

def FileFolderExample():
  # Specifies the path to the desired file
  sPath = "C:\\MyFiles\\MyFolder\\FileName.txt"
  # Obtains the path to the folder containing the file
  sFolder = aqFileSystem.GetFileFolder(sPath)
  # Posts the folder path to the test log
  Log.Message(sFolder)
  
# The routine produces the following output
# C:\MyFiles\MyFolder\

VBScript

Sub FileFolderExample

  ' Specifies the path to the desired file
  sPath = "C:\MyFiles\MyFolder\FileName.txt"
  
  ' Obtains the path to the folder containing the file
  sFolder = aqFileSystem.GetFileFolder(sPath)
  
  ' Posts the folder path to the test log
  Log.Message(sFolder)
  
End Sub
 
' The routine produces the following output
' C:\MyFiles\MyFolder\

DelphiScript

function FileFolderExample;
var sPath, sFolder;
begin

  // Specifies the path to the desired file
  sPath := 'C:\MyFiles\MyFolder\FileName.txt';
  
  // Obtains the path to the folder containing the file
  sFolder := aqFileSystem.GetFileFolder(sPath);
  
  // Posts the folder path to the test log
  Log.Message(sFolder);
  
end;
 
{
The routine produces the following output

C:\MyFiles\MyFolder\
}


C++Script, C#Script

function FileFolderExample()
{

  // Specifies the path to the desired file
  var sPath = "C:\\MyFiles\\MyFolder\\FileName.txt";
  
  // Obtains the path to the folder containing the file
  var sFolder = aqFileSystem["GetFileFolder"]( sPath );
  
  // Posts the folder path to the test log
  Log["Message"]( sFolder );
  
}
 
/*
The routine produces the following output

C:\MyFiles\MyFolder\
*/


See Also

Working With Files From Scripts
GetFileName Method
GetFileExtension Method
GetFileDrive Method

Highlight search results