The File object
The File object is obtained using FileSystemObject. It is used to manipulate or obtain information about a file. To use a File object simply:
- Create an instance of the FSO object:
- Open a file by creating a File object, for example:
- Use a method or property of the File object, for example:
Here is a summary of collections, properties and methods of the File object:
| Objet File|
| Collections|| Propreties|| Methods|
The Attributes property
The Attributes property allows you to set or retrieve the attributes of a particular file or folder. The returned value, defining the attributes of the file is calculated by summing the values ??of the attributes of the file:
| Value|| Description|
|0||Normal. File without attribute|
|1||ReadOnly. Read-only file that can be read only (not editable).|
|2||Hidden. Hidden file|
|4||System. System file, necessary for the proper functioning of the system|
|8||Volume. Volume label of a disk drive.|
|16||Directory. Folder (Directory)|
|32||Archive. File modified since the previous backup.|
|64||Alias. This is a shortcut.|
|128||Compressed. It is a compressed file|
For an archive, hidden, read-only, the return value will be:
32+2+1 = 35
DateCreated property allows you to set or retrieve the date and time of creation of a particular file or folder.
DateLastAccessed property allows you to set or retrieve the date and time of last access of a particular file or folder.
DateLastModified property to set or retrieve the date and time at which the last modification was made to a file or folder
Drive property contains the name of the drive on which the target file or folder is located.
The Name property allows you to set or retrieve the name of the file or folder in question, without indicating the path.
The ParentFolder property contains the name of the parent folder of the specified file or folder.
The Path property contains the absolute path of the specified file or folder.
The ShortName property contains the name of the specified file or folder in its abbreviated form.
The ShortPath property contains the path to the file or folder specified in its abbreviated form.
The Size property contains the size of the specified file, in bytes.
The Type property containsinformation about the type of the specified file or folder.
Copy method contains information about the type of file or folder specified.
Original document published on CommentcaMarche.net