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:
- ,
Properties
- Property FileSeparator() As (Read Only)
-
Returns the file separator string.
(usually, \\ on Windows and / on UNIX)
- Parameters:
-
- oTmpDirectory
- The file separator string. dd>
- Property PathSeparator() As (Read Only)
-
Returns the path separator string.
(usually,; on Windows and : on UNIX)
- Parameters:
-
- oTmpDirectory
- The path separator string. dd>
- 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. dd>
Methods
- 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"). dd>
- iPathChunk2
- The second path chunk (for instance "local\myfile.txt"). dd>
- oPath
- The resulting path (for instance "E:\\tmp\\local\\myfile.txt"). dd>
- Sub CopyFile( iPathSource, iPathDestination, iOverwrite)
-
Copies a file from one location to another.
- Parameters:
-
- iSourcePath
- The full path of the source file. dd>
- iDestinationPath
- The full destination path where the source file is to be copied. dd>
- 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)
- 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. dd>
- 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")
- 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. dd>
- 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. dd>
- 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)
- 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. dd>
- 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")
- 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")
- 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")
- 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")
- 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")
- 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")
- Func GetFolder( iPath) As
-
Returns a folder using its full path.
- Parameters:
-
- iPath
- The full path of the folder to retrieve. dd>
- 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\")