FileSystemObject object, filesystemobject

Source: Internet
Author: User

FileSystemObject object, filesystemobject

To implement file operations in javascript, FileSystemobject objects are primarily used.

It is very easy to program with FileSystemObject object. The steps are as follows:

1. Create a FileSystemObject object
Var fso = new ActiveXObject ("Scripting. FileSystemObject ");
2. After creating an object instance, you can use the object-related methods.
For example, create a text file:

  <script language="javascript">      var fso = new ActiveXObject("Scripting.FileSystemObject");   var newFileObject = fso.CreateTextFile("c:\\boat.txt", true);  </script>

3. Access Object Attributes
To access the relevant properties of an object, you must first create a handle pointing to the object:
GetDrive obtains the drive information, GetFolder obtains the folder information, and GetFile obtains the file information.
In the following code, textfile is the handle pointing to the file c: \ boat.txt:

var fso = new ActiveXObject("Scripting.FileSystemObject");var textfile = fso.GetFile("c:\\boat.txt");alert("File last modified: " + textfile.DateLastModified);

For objects created using the create method, you can directly use the name of the handle created using the create method:

var fso = new ActiveXObject("Scripting.FileSystemObject");var textfile = fso.createtextfile("c:\\boat.txt",true");alert("File last modified: " + textfile.DateLastModified);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.