Click or drag to resize

FileSpec Class (Typed)

X#
Create a file specification, which provides a useful framework for managing file names and paths.
Inheritance Hierarchy
Object
  FileSpec
    DbFileSpec

Namespace:  XSharp.VO.SDK
Assembly:  XSharp.VOSystemClasses (in XSharp.VOSystemClasses.dll) Version: 2.21
Syntax
[TypesChangedAttribute]
 CLASS FileSpec
Request Example View Source

The FileSpec type exposes the following members.

Constructors
  NameDescription
Public methodFileSpec
Construct a file specification.
Top
Properties
  NameDescription
Public propertyCode exampleAttributes
One or more of the following characters concatenated into a string, indicating the attributes of the file represented by this file specification:
Public propertyDateChanged
A date value denoting when the file was created or last changed. If the file is not found, NULL_DATE is returned.
Public propertyCode exampleDrive
A string representing the drive defined to this file specification.
Public propertyErrInfo
Return the error object from the last Copy() or Move() operation.
Public propertyExtension
A string representing the extension defined to this file specification.
Public propertyCode exampleFileName
A string representing the file name defined to this file specification.
Public propertyCode exampleFullPath
A string representing the full path name defined to this file specification.
Public propertyCode examplePath
A string representing the path defined to this file specification.
Public propertySize
A numeric value representing the size, in bytes, of the file represented by this file specification.
Public propertyTimeChanged
A string indicating the time when the file was created or last changed.
Top
Functions
  NameDescription
Public methodCode exampleAppendToPath
Append a subdirectory to the end of this file specification's path.
Public methodCode exampleCopy(String, Logic)
Make a copy of the file represented by this file specification.
Public methodCode exampleCopy(FileSpec, Logic)
Make a copy of the file represented by this file specification.
Public methodDelete
Delete the file represented by this file specification.
Public methodError(Error)
Provide a method for handling error conditions raised during FileSpec processing. This is an event handler: it is automatically called by other methods; the developer does not normally need to call the error method, but might want to replace or amend it.
Public methodError(Error, Symbol)
Provide a method for handling error conditions raised during FileSpec processing. This is an event handler: it is automatically called by other methods; the developer does not normally need to call the error method, but might want to replace or amend it.
Public methodCode exampleFind
Search the disk for the file represented by this file specification, indicate if it exists, and if so, store its full path information in this file specification for future reference.
Public methodCode exampleMove(String, Logic)
Move the file represented by this file specification to a new location.
Public methodCode exampleMove(FileSpec, Logic)
Move the file represented by this file specification to a new location.
Public methodCode examplePathUp
Remove the last subdirectory from the end of this file specification's path.
Public methodCode exampleRename(String, Logic)
Rename the file represented by this file specification.
Public methodCode exampleRename(FileSpec, Logic)
Rename the file represented by this file specification.
Top
Remarks
A file specification is intended as a way of storing and managing name- and path-related information for a file. It provides some methods for copying, moving, deleting and renaming files, as well as access methods for retrieving information about the file. If the path is not specified using the assign methods provided by the FileSpec class, it is obtained by the SetDefault() and SetPath() functions. This class allows you to manage this data for all different types of files in a common way. Because of this, it does not provide any methods for processing a file, such as reading and writing it, as such methods would depend on the type of file it is. For example, .DBF files can be processed with the DBServer object; other files can be processed with either functions or customized FileSpec subclasses that have been customized for handling different types of files.
Examples
File specifications are often used as arguments to DBServer objects and methods. For example, to copy selected records from one file to another:
X#
 1// Source file
 2oFSSource := FileSpec{"c:\data\customer"}
 3// For the target file, use path of source file
 4oFSTarget := FileSpec{oFSSource:FullPath}
 5// Change file name for target file
 6oFSTarget:FileName := "nycust"
 7// Open source file in server object
 8oDBSource := DBServer{oFSSource}
 9// Copy records to target file
10oDBSource:CopyDB(oFSTarget,,{||STATE="NY"})
A FileSpec object is also a convenient way to find the current directory and then search in subdirectories according to a logical structure:
X#
1oFileSpec := FileSpec{}
2oFileSpec:Path := CurDir()
3oFileSpec:AppendToPath("data")
4oFileSpec:FileName := "custdata"
5oDB := DBServer{oFileSpec}
See Also