File systems are one of the most important parts of all operating systems. scripts often need to access and manage files and folders, fileSystemObject (FSO) is the top-level object for accessing desktops and file systems in vbs. This object is particularly complex and is the core of vbs file operations. The content of this section should be well known.
FSO contains the following common objects:
Drive object: contains information about storage devices, including hard drives, optical drives, ramdisks, and network drives.
Drives collection: provides a list of physical and logical drives
File object: Check and process files
Files set: provides a list of files in a folder.
Folder object: Check and process folders
Folders set: provides a list of folder subfolders.
Textstream object: read/write text files
Common FSO methods include:
Buw.path: adds the file path information to the existing file path.
Copyfile: copy an object
Copyfolder: copy a folder
Createfolder: Create a folder
Createtextfile: Creates text and returns a textstream object.
Deletefile: delete an object
Deletefolder: delete a folder and all its contents.
Driveexits: determines whether the drive exists
Fileexits: determines whether a file exists
Folderexists: determines whether a folder exists
Getabsolutepathname: returns the absolute path of a folder or file.
Getbasename: returns the basic path of a file or folder.
Getdrive: returns a dreve object.
Getdrivename: returns the name of a drive.
Getextensionname: returns the extension.
GetFile: returns a file object.
Getfilename: returns the name of the file in the folder.
Getfolder: returns a folder object.
Getparentfoldername: returns the parent folder of a folder.
Getspecialfolder: returns the object pointer to a special folder.
Gettempname: returns the name of a randomly generated file or folder that can be used by createtextfile.
Movefile: Move a file
Movefolder: Move a folder
Opentextfile: open an existing file and return a textstream object.