Javascript FSO GetFile Method
Javascript FileSystemObject (FSO) GetFile method provides the functionality to access the properties and methods associated with file object. FSO GetFile method returns the File object that further provides the access to all such properties and methods. GetFile method allows you to access the properties such as Name, Date last accessed, date last modified, path, parent folder etc. Methods supported by GetFile method are copy, move, delete, open text file as text stream etc. GetFile method targets the specified file and performs each action on it based on the applied method.
Syntax for Javascript FSO GetFile Method
fso.GetFile( filePath );
As shown in the above syntax of FSO GetFile method it accepts only 1 parameter as filePath along with its name.
Example of FSO GetFile Method
<script type="text/javascript">
// initialize ActiveXObject and create an object of Scripting.FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
// returns the file object associated with the specified file
var fileObj = fso.GetFile("C:\\Temp\\myFolder\\File.txt");
document.write(fileObj.Name);
fso = null;
// Output:
// file.txt
</script>
FSO File Object Properties
- Attributes: gets or sets the attributes of the file.
- DateCreated: returns the date and time when the file was created.
- DateLastAccessed: returns the date and time when the file was last accessed.
- DateLastModified: returns the date and time when the file was last modified.
- Drive: returns the drive letter retrieved from the path of the file.
- Name: returns the name of the file.
- ParentFolder: returns the name of the parent folder.
- Path: returns the complete path of the file.
- ShortName: returns the short name of the file according to 8.3 naming convention of file system.
- ShortPath: returns the short path of the file according to 8.3 naming convention of file system.
- Size: returns the size of the file in bytes.
- Type: returns the type of the file.
FSO File Object Methods
- Copy: copies the file to the specified location.
- Delete: deletes the file
- Move: moves the file to the specified location.
- OpenAsTextStream: opens the file as textstream and allows reading, writing or appending it.
Continue to next tutorial: Javascript FSO GetFileName Method to learn how to get the file from the specified path.

* will not be published
* hint: http://www.example.com