JavaScript Scripting FileSystemObject works on client side that provides the functionality to access the file system of client’s machine. Using fso i.e. FileSystemObject you can perform various actions on the files system of client machine but provided that the client’s web browser allows the JavaScript automation server to create the object. Functionality of FileSystemObject is only possible if the web browser of client’s PC has very low security. Low security means web browser allows creating the Javascript signed or unsigned activeX objects that could access the client’s machine. So if you are using a FileSystemObject through Javascript ActiveXObject method then it doesn’t mean that you can do any action on client’s machine very easily.

Javascript Scripting FileSystemObject Properties and Methods

Following are the properties and methods of FileSystemObject that allows you to access the files and folders at the client side:

Property

1. Drives: Javascript FileSystemObject allows the access of only 1 object after its initialization. Drives property returns the collection of drives on the client’s PC.

Further methods of FSO allow the use of different types of properties associated with files such as attributes, DateCreated, DateLastAccessed etc.

Methods

  1. BuildPath: Builds a complete path by concatenating two parameter values such Path and Name.
  2. CopyFile: Copies files from source to the destination path. Also allows you to overwrite the existing file.
  3. CopyFolder: Copies folder from source to the destination path. It also allows you to overwrite the destination folder if it already exists.
  4. CreateFolder: Creates a new folder with specified name at the specified location.
  5. CreateTextFile: Creates a text file at the specified location with given name and returns TextStream. This TextStream resultant further provides its own properties and methods that allow you to read and write text in the newly created file.
  6. DeleteFile: Deletes the file at the specified location.
  7. DeleteFolder: Deletes the folder at the specified path along with its contents.
  8. DriveExists: Checks the Drive whether it exists or not and returns the Boolean result.
  9. FileExists: Checks the file whether it exists at the specified location and returns the Boolean result.
  10. FolderExists: Checks the folder whether it exists at the specified location and returns the Boolean result.
  11. GetAbsolutePathName: Returns the absolute path of the specified file or folder.
  12. GetBaseName: Returns the base of file or folder from the specified path. If path contains filename then it returns the filename without file extension. 
  13. GetDrive: Accepts the name of the drive as its letter such as C,D,E that exists on the client’s PC and allows the access to properties of Drive such e.g.: AvailableSpace, DriveType, FileSystem etc.
  14. GetDriveName: Returns the drive letter from the specified path.
  15. GetExtensionName: Returns the extension of file specified in the path.
  16. GetFile: Returns a file object for the specified file path and allows the access to its properties such as DateCreated, DateLastAccessed etc.
  17. GetFileName: Return the file name with extension from the specified path.
  18. GetFolder: Returns a folder object for the specified file path and allows the access to its properties such as DateCreated, DateLastAccessed, Files etc.
  19. GetParentFolderName: Returns the parent folder name for the specified file or folder that is nearest to the file name in the location path.
  20. GetSpecialFolder: It returns the path to the special folder of window such as Temporary files folder, system32 folder etc.
  21. GetTempName: Return the temporary name for a file that can used to save the temporary data in the client’s PC. This method returns the randomly generated file names e.g.: rad79FF.tmp
  22. MoveFile: It provides the functionality to move the file from source to destination path.
  23. MoveFolder: It provides the functionality to move the folder from source to destination path.
  24. OpenTextFile: This method of FileSystemObject returns the TextStream for the specified file that can be altered using its accessible functions and properties.

Continue to next tutorial: How to Create FileSystemObject in Javascript to learn about creating the ActiveX object for working with client side files.

Recent JavaScript Tutorials

Javascript FSO ShortPath property

Javascript FileSystemObject (FSO) provides a ShortPath property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Path Property

Javascript FileSystemObject (FSO) provides the Path property that can be accessed through the file object or folder object returned by the GetFile or GelFolder method

Javascript FSO Type property

Javascript FileSystemObject (FSO) provides a Type property that can be accessed through file object or folder object returned by the GetFile or GetFolder method

Javascript FSO ShortName property

Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Name Property

Javascript FileSystemObject (FSO) provides a Name property that can be accessed using file object or folder object.