Javascript-Folder object

Source: Internet
Author: User

Description:

Provides access to folder properties.

Attribute:

Attribute Description
Attributes Sets or returns the attributes of a file or folder.
Datecreated Returns the creation time of the specified file or folder.
Datelastaccessed Returns the last time the file or folder was created.
Datelastmodified Returns the last modification date and date of the specified file and folder.
Drive Returns the drive letter of the drive where the specified file or folder is located.
Files Returns a set of files consisting of all file objects in the specified folder, including files with hidden files and system file attributes.
Isrootfolder If the specified folder is the root folder, true is returned; otherwise, false is returned.
Name Set or return the name of the file or folder
Parentfolder Returns the parent folder object of the specified file or folder.
Path Returns the path of the specified file, folder, or drive.
Shortname Return short name
Export path Return short path
Size For folders, the size of all files and subfolders in all subfolders contained in the folder is returned in bytes.
Subfolders Returns a folder set consisting of files in the specified folder, including files with hidden and system file attributes.
Type Returns information about a file or folder.

 

Example:

Example Effect
VaR folderpath =" D: \ test \\ "; Var FSO = New Activexobject (" Scripting. FileSystemObject "); Var folder = FSO. getfolder (folderpath); display (" Datecreated: "+ Folder. datecreated); display ("Datelastaccessed: "+ Folder. datelastaccessed); display (" Datelastmodified: "+ Folder. datelastmodified); display (" Drive: "+ Folder. Drive); display (" Isrootfolder: "+ Folder. isrootfolder); display (" Name: "+ Folder. Name); display (" Parentfolder: "+ Folder. parentfolder); display (" Path: "+ Folder. Path); display (" Shortname: "+ Folder. shortname); display (" Export path: "+ Folder. Folder path); display (" Size: "+ Folder. size); display (" Type: "+ Folder. type); function display ( Value ) {Document. Write ( Value +" <Br/> ");}
VaR folderpath =" D: \ test \\ "; Var FSO = New Activexobject (" Scripting. FileSystemObject "); Var folder = FSO. getfolder (folderpath); var Fe = New Enumerator (Folder. files ); While (! Fe. atend () {document. Write (Fe. Item () +" <Br/> "); Fe. movenext ();} document. Write (" <HR/> "); Fe = New Enumerator (Folder. subfolders ); While (! Fe. atend () {display (Fe. Item (); Fe. movenext ();} function display ( Value ) {Document. Write ( Value +" <Br/> ");}

 

 

Attribute: Attributes

Description: sets or returns the attributes of a file or folder.

Constant Value Description
Normal 0 Common File
Readonly 1 Read-Only files
Hidden 2 Hide a file
System 4 System Files
Volume 8 Disk Drive Volume label
Directory 16 Folder or directory
Artichive 32 File Modified after last backup
Alias 64 Link or shortcut
Compressed 128 Compression not found

Example:

Example Effect
VaR folderpath ="D: \ test \\"; Var FSO =NewActivexobject ("Scripting. FileSystemObject"); Var folder = FSO. getfolder (folderpath); display (Folder. attributes); function display (Value) {Document. Write (Value+"<Br/>");}
16

 

Method:

Method Description Remarks
OBJ. Copy (destination [, overwrite]) Copy the specified folder from one location to another OBJ: folder
Destination: required. The destination location of the copied file or folder.
Overwrite: Optional. The value of overwrite is true. Otherwise, the value of overwrite is false. The default value is true.
OBJ. Delete ([force]) Deletes a specified folder. OBJ: file or folder
Force: Optional. boolean value. True if you want to delete a file or folder with the read-only attribute. Otherwise, false.
OBJ. Move (destination) Cut the specified file or folder from one location to another Destination: Destination location for moving folders
obj. createtextfile (filename, overwrite, Unicode) open the specified object and return a textstream object.
read, write, or append the object through this object
filename: should be the name of the file object
iomode: Optional. The specified input/output mode can be one of the three constants:
forreading, forwriting, forappend
Create: create a file
fomat: Optional. Use one of the three-state values to specify the file opening format,
if ignored, the file is opened in ASCII format
Related Article

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.