FileBrowser

Object Hierarchy

Introduced

v2.0

Description

A simple file browser that can be used in scripts to let users specify the full path name of a single file that needs to be either saved or opened. You can access the FileBrowser through the XSIUIToolkit object. This is a concrete (leaf) object.

Methods

ShowOpen ShowSave    
       

Properties

DialogTitle FileBaseName FileExtension FileName
FilePath FilePathName Filter InitialDirectory

Examples

1. VBScript Example

'VBScript example
dim oFileBrowser
set oFileBrowser = XSIUIToolkit.FileBrowser
oFileBrowser.DialogTitle = "Select a file"	' set the title of the file browser
oFileBrowser.InitialDirectory = "c:\"		' set the initial directory
oFileBrowser.FileBaseName = "foo"			' set the default file name
oFileBrowser.Filter = "Text (*.txt)|*.txt|All Files (*.*)|*.*||"	' set the filters
oFileBrowser.ShowOpen					' show an open file dialog
logmessage VB_LF
' if the user selected a file
If oFileBrowser.FilePathName <> "" Then
' display info on the selected file
	logmessage "Details on the file that was selected:"
	logmessage "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	logmessage "File path name : " & oFileBrowser.FilePathName
	logmessage "File Name      : " & oFileBrowser.FileName
	logmessage "File base name : " & oFileBrowser.FileBaseName
	logmessage "File extension : " & oFileBrowser.FileExtension
	logmessage "Path           : " & oFileBrowser.FilePath
' the user did not select a file
Else
logmessage "User pressed cancel"
End If

2. JScript Example

// JScript example of FileBrowser object
var initialDir ;
if ( Application.Platform == "Win32" )
{
	initialDir = "c:\\temp\\" ;
}
else
{
	initialDir = "/var/tmp" ;
}
var oUIToolkit = new ActiveXObject("XSI.UIToolKit") ;
var oFileBrowser = oUIToolkit.FileBrowser ;
oFileBrowser.DialogTitle = "Select a file" ;
oFileBrowser.InitialDirectory = initialDir ;
oFileBrowser.Filter = "All Files (*.*)|*.*||" ;
oFileBrowser.ShowOpen() ; 
if ( oFileBrowser.FilePathName != "" )
{
	//display info on the selected file
	logmessage( "\nDetails on the file that was selected:" );
	logmessage( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
	logmessage( "File path name : " + oFileBrowser.FilePathName);
	logmessage( "File Name      : " + oFileBrowser.FileName);
	logmessage( "File base name : " + oFileBrowser.FileBaseName);
	logmessage( "File extension : " + oFileBrowser.FileExtension);
	logmessage( "Path           : " + oFileBrowser.FilePath);
}
else
{
	logmessage( "User pressed cancel" ) ;
}

See Also

XSIUIToolkit