All Frameworks  Object Hierarchy  This Framework  Indexes   

FileSystem (Object)

Represents the file system object.
Role: The file system object allows you to access and manipulate folders and files. It can check the existence of, get, create, delete, or copy folders and files.
See also:
Folder, File

Property Index

FileSeparator
Returns the file separator string.
PathSeparator
Returns the path separator string.
TemporaryDirectory
Returns the temporary system directory.

Method Index

ConcatenatePaths
Concatenates two path chunks to make a new path.
CopyFile
Copies a file from one location to another.
CopyFolder
Recursively copies a folder from one location to another.
CreateFile
Creates a file and returns the associated file object.
CreateFolder
Creates a folder and returns the associated folder object.
DeleteFile
Deletes a file.
DeleteFolder
Deletes a folder.
FileExists
Returns whether a given file exists.
FolderExists
Returns whether a given folder exists.
GetFile
Returns a file using its full path.
GetFolder
Returns a folder using its full path.

Properties


o Property FileSeparator() As (Read Only)
Returns the file separator string. (usually, \\ on Windows and / on UNIX)
Parameters:
oTmpDirectory
The file separator string.
o Property PathSeparator() As (Read Only)
Returns the path separator string. (usually,; on Windows and : on UNIX)
Parameters:
oTmpDirectory
The path separator string.
o Property TemporaryDirectory() As (Read Only)
Returns the temporary system directory. (usually, C:\\temp on Windows and /tmp on UNIX)
Parameters:
oTmpDirectory
A folder which corresponds to the temporary system directory.

Methods


o Func ConcatenatePaths( iPathChunk1,
iPathChunk2) As
Concatenates two path chunks to make a new path. Either path chunk can be empty. The resulting path does not have to exist. The method automatically corrects improper path separators (/ Unix separators used on a Windows platform are automatically replaced by \\ and vice versa).
Parameters:
iPathChunk1
The first path chunk (for instance "E:\\tmp").
iPathChunk2
The second path chunk (for instance "local\myfile.txt").
oPath
The resulting path (for instance "E:\\tmp\\local\\myfile.txt").
o Sub CopyFile( iPathSource,
iPathDestination,
iOverwrite)
Copies a file from one location to another.
Parameters:
iSourcePath
The full path of the source file.
iDestinationPath
The full destination path where the source file is to be copied.
iOverwrite
Boolean value that is True if an existing file with the same name can be overwritten; False if it is not, and the copy doesn't take place.
Example:
This example copies the file C:\Tests\File1 to C:\Tests\File2 from the file system object FileSys, except if a file with the name C:\Tests\File2 already exists.
 FileSys.CopyFile("C:\Tests\File1", "C:\Tests\File2", False)
 
o Sub CopyFolder( iSourcePath,
iDestinationPath)
Recursively copies a folder from one location to another. Role: The folder is copied along with its files, and all its subfolders and their own files.
Parameters:
iSourcePath
The full path of the source folder.
iDestinationPath
The full destination path where the source folder, its files, and its subfolders are to be copied.
Example:
This example copies the folder "C:\Tests\Fold1" to "C:\Tests\Fold2" of the file system object FileSys.
 FileSys.CopyFolder("C:\Tests\Fold1", "C:\Tests\Fold2")
 
o Func CreateFile( iPath,
iOverwrite) As
Creates a file and returns the associated file object.
Parameters:
iPath
The full path where the file is to be created.
iOverwrite
Boolean value that is True if an existing file with the same name can be overwritten; False if it is not, and the creation doesn't take place.
Returns:
The created file
Example:
This example creates the file C:\Tests\File1 and retrieves it in the file object FileObj from the file system object FileSys, except if a file with the name C:\Tests\File1 already exists.
 Dim FileObj As File
 Set FileObj = FileSys.CreateFile("C:\Tests\File1", False)
 
o Func CreateFolder( iPath) As
Creates a folder and returns the associated folder object.
Parameters:
iPath
The full path where the folder is to be created.
Returns:
The created folder object. If the folder already exists, the method fails.
Example:
This example creates the folder "C:\Tests\Fold1" and retrieves it in FoldObj from the FileSystem FileSys.
 Dim FoldObj As Folder
 Set FoldObj = FileSys.CreateFolder("C:\Tests\Fold1")
 
o Sub DeleteFile( iPath)
Deletes a file.
The method fails if the folder doesn't exist.
Parameters:
iPath
The full path of the file to delete.
Example:
This example deletes the file "C:\Tests\File" from the file system object FileSys.
 FileSys.DeleteFile("C:\Tests\File1")
 
o Sub DeleteFolder( iPath)
Deletes a folder.
The method fails if the folder doesn't exist.
Parameters:
iPath
The full path of the folder to delete.
Example:
This example deletes the folder "C:\Tests\Fold1" from the FileSystem FileSys.
 FileSys.DeleteFolder("C:\Tests\Fold1")
 
o Func FileExists( iPath) As
Returns whether a given file exists.
True if the file exists.
Parameters:
iPath
The full path of the file.
Example:
This example retrieves in Exists whether the file "C:\Tests\File1" exists in the file system object FileSys.
 Dim Exists As Boolean
 Exists = FileSys.FileExists("C:\Tests\File1")
 
o Func FolderExists( iPath) As
Returns whether a given folder exists.
True if the folder exists.
Parameters:
iPath
The full path of the folder.
Example:
This example retrieves in Exists whether the folder "C:\Tests\Fold1" exists in the file system object FileSys.
 Dim Exists As Boolean
 Exists=FileSys.FolderExists("C:\Tests\Fold1")
 
o Func GetFile( iPath) As
Returns a file using its full path.
The method fails if the folder doesn't exist.
Parameters:
iPath
The full path of the file to retrieve.
Example:
This example retrieves the file C:\Tests in the FileObj from the file system object FileSys.
 Dim FileObj As File
 Set FileObj = FileSys.GetFile("C:\Tests")
 
o Func GetFolder( iPath) As
Returns a folder using its full path.
Parameters:
iPath
The full path of the folder to retrieve.
Returns:
The retrieved folder. If the folder doesn't exist, the method fails.
Example:
This example retrieves the C:Tests folder in FoldObj from the file system object FileSys.
 Dim FoldObj As Folder
 Set FoldObj = FileSys.GetFolder("C:\Tests\")
 

Copyright © 2003, Dassault Systèmes. All rights reserved.