Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

VBScript File System Object: An Introduction to FSO and Its Methods and Properties, Study notes of Computer Numerical Control

An overview of the filesystemobject (fso) in vbscript, which serves as the access point for a hierarchy of objects used to manipulate drives, folders, and files. The main fso object and its sub-objects: filesystemobject, drive, file, folders, textstream, and their respective methods and properties. It also includes examples of creating folders and files, getting folder and file information, and copying and moving folders.

Typology: Study notes

2010/2011

Uploaded on 09/06/2011

nirmalya
nirmalya 🇮🇳

4.5

(2)

17 documents

1 / 27

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
FILE SYSTEM OBJECT
fso.html
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b

Partial preview of the text

Download VBScript File System Object: An Introduction to FSO and Its Methods and Properties and more Study notes Computer Numerical Control in PDF only on Docsity!

FILE SYSTEM OBJECT

fso.html

FileSystemObject

  • (^) The standard Visual Basic (VB) file input and output commands are not available in VBScript.
  • (^) All the file access is provided through the methods and properties of special objects

FSO Objects (Contd…)

3. File  (^) (object) Contains methods and properties that allow us to create, delete or move a file. Also allows us to query the system for a file name, path and various other properties. 4. Files  (^) (Collection) provides a list of all files contained with in a folder.

FSO Objects (Contd…)

5. Folder  (^) (object) Contains methods and properties that allow you to create, delete or move folders. Also allows us to query the system for folder names, paths and various other properties. 6. Folders  (^) (Collection) provides a list of all the folders within a folder.

  • (^) The FSO is a kind of “Master Object” that serves as the access point for family of objects.
  • (^) All of the objects in the FileSystemObject hierarchy together provide the functionality for accessing and manipulating window file system.
  • (^) The root object “FileSystemObject” is the access point for all other objects.
  • (^) To do anything on with drives, folders or files FileSystemObject must be created first.
  • (^) Creating FileSystemObject
    • (^) Set FSO=CreateObject(“scripting.FileSystemObject”)

FSO object’s various methods

  1. CreateFolder()
  2. CreateTextFile()
  3. GetFolder()
  4. GetFile()
  5. GetDrive()
  6. CopyFolder()
  7. MoveFolder()
    1. FolderExists()
    2. GetDriveName()
    3. GetExtensionName( )
    4. FileExists()

Creating a Folder

Dim FSO, FolderObj Set FSO= CreateObject(“scripting.FileSystemObject”) Set FolderObj=FSO.CreateFolder(“D:\ITA”);

GetFolder()

  • (^) This method returns a folder object of the folder whose path is specified as parameter. Set FSO= CreateObject(“scripting.FileSystemObject”) Set FolderObj=FSO.GetFolder(“D:\ITA”);

GetFile()

  • (^) This method returns a file object of the file whose path is specified as parameter. Set FSO= CreateObject(“scripting.FileSystemObject”) Set FileObj=FSO.GetFile(“D:\ITA\test.txt”);

CopyFolder()

FSO.CopyFolder source, destination dim FSO set FSO=CreateObject("Scripting.FileSystemObject") If FSO.FolderExists("c:\sourcefolder\website") Then FSO.CopyFolder "c:\sourcefolder\website", "c:
destfolder\” End If

MoveFolder()

FSO.MoveFolder source, destination

GetDriveName(path)

dim FSO, a Set FSO =CreateObject("Scripting.FileSystemObject") a = filesys.GetDriveName(“d:\ITA\test.txt”) ‘a=“d:”

GetExtensionName(path)

FSO.GetExtensionName(path)

  • (^) Used to return a string containing the extension name of the supplied path.
  • (^) If no extension found in the supplied path method will return an empty string.