File System Object(FSO) in UFT or QTP or VBScript

0
87
Spread the love
  • 25
  • 34
  • 12
  • 23
  •  
  •  
  •  
  •  
  •  
  •  
    94
    Shares

Introduction to FSO in VBScript or UFT

File system Object enables us to work with files like read, write, find, search a file and folder etc. FSO is an inbuilt object available in VBScript and VBScript driven UFT.FileSystemObject library provides various objects which allow the coders to interact with Windows File System.

FileSystemObject is a library under which we have several Objects or collections to work with files. FileSystemObject works only on windows environment. FSO can work with WSH seamlessly.

Elements available in FSO Object Model

Object/Collection Details
FileSystemObject This is the root or main object of the class.This is the entry point to enter into the FSO.
We need to create object of FSO first in order to access several other methods and properties.It provides the below property

  • Drives

It provides several other functions like

  • CreateFolder()
  • FileExists(),
  • DrivesExists()
  • CopyFiles()
  • BuildPath()
  • CopyFolder()
  • CreateTextFile()
  • DeleteFile()
  • DeleteFolder()
  • FolderExists()
  • GetAbsolutePathName()
  • GetBaseName()
  • GetDrive()
  • GetDriveName()
  • GetExtensionName()
  • GetFile()
  • GetFileName()
  • GetFolder()
  • OpenTextFile()
  • MoveFolder()
  • MoveFile()
  • GetTempName()
  • GetParentFolderName()
  • GetSpecialFolder()
Drive This object provides an access to underlying disk properties along with a presentation of a logical or physical drive available in the computer where
we are running the script.It provides the below properties

  • AvailableSpace
  • LastAccessed
  • RootFolder
  • DriveLetter
  • DriveType
  • Path
  • IsReady
  • FreeSpace
  • FileSystem
  • SerialNumber
  • ShareName
  • TotalSize
  • VolumeName

It does not have any methods.

Drives -Drive Collection It is a child of FileSystemObject denotes a collection of drives(including media drives without
removable media).It can hold information about one or more drives.It provides two properties

  • Count
  • Item

It does not have any methods.

File It represents a file available in the folder or a drive.We can use either FileSystemObject.GetFile() method or
Folder or Files collection to obtain a File. It provides the below properties

  • ParentFolder
  • DateCreated
  • Attributes
  • DateLastModified
  • DateLastAccessed
  • Drive
  • Name
  • Path
  • ShortName
  • ShortPath
  • Size
  • Type

It also provides the below methods

  • Copy
  • Delete
  • Move
  • OpenAsTextStream
Files-File Collection It is a child of Folder object and denotes a collection of Files. It provides two properties

  • Count
  • Item.

We can use Folder.Files in order to get a File

It does not provide any methods.

Folder It represents the folder on a drive.We can get reference to a folder by using Drive.RootFolder or CreateFolder() ,
GetFolder() , and GetSpecialFolder() methods. It provides the below properties

  • Attribute
  • DateCreated
  • DateLastModified
  • DateLastAccessed
  • Drive
  • Name
  • Path
  • ShortName
  • ShortPath
  • Size
  • Type
  • Files
  • IsRootFolder
  • ParentFolder
  • SubFolders

It provides methods like-

  • Copy
  • Delete
  • Move
  • OpenAsTextStream
Folders- Collection of Folders It represents the collection of folder. We can get the same using Folder.SubFolders property.

This collection provides two properties

  • Count
  • Item

and a method

  • Add()

Add() method adds a subfolder to the collection.

TextStream This object represents the stream of text read from a file or written to a file or going to or coming from windows standard I/O.
This object has a line pointer and a character pointer.The direction of reading or writing is from top to bottom,Character by
Character or line by line.We get this object when we use File.OpenAsTestStream() or Folder.CreateTextFile() or OpenTextFile() or getStandardStream().  It provides properties or methods like Read , Write , ReadLine , WriteLine ,AtEndOfLine.
AtEndOfLine .

FileSystemObject Object

This is the foundation object to access the files and drives in Microsoft environment. The Properties and methods of FileSystemObject is given as:

FileSystemObject Properties
Properties Comment
Drives Returns the collection of drives including network drives available in the file system.
FileSystemObject Methods
Methods Comment
CopyFile (sourceFilePath,
destinationFilePath, overwrite)
It copies a specified file to the provided destination folder.Overwrite is a boolean argument
indicating overwrite is permitted if set as Yes.It will throw an error if there is a same file name
already exists and overwrite flag is false.
BuildPath(path,name) This method adds the folder to the path.It can automatically add separator.It can not validate the correctness of the path.
CopyFolder (sourcePath,
destinationPath, overwrite)
It copies a specified folder to the provided destination folder.Overwrite is a boolean argument
indicating overwrite is permitted if set as Yes.It will throw an error if there is a same folder name
already exists and overwrite flag is false.
CreateFolder (folderName) It creates a folder with the name specified and return the object as a reference.If the folder name already exist and we are
trying to create one more with the same name,It will throw an error
CreateTextFile (filename,
overwrite, unicode)
This method creates a text file in the specified folder with the specified fileName.
Overwrite is a boolean argument
indicating overwrite is permitted if set as Yes. The default overwrite parameter is false.
The last parameter is the indication of what format the text will be stored. Default for Unicode is false.If we set it as true the whole text will be placed in Unicode.
DeleteFile (fileName,
force)
Deletes a file or files .The force parameter may be set as true.However force is an optional parameter.
By default it is false.The file/files will be deleted even if the read only attribute is set by the user for any file.
DeleteFolder (folderName,
force)
Deletes a folder or folders.The force parameter may be set as true.However force is an optional parameter.
By default it is false.The folder/folders will be deleted even if the read only attribute is set by the user for any file.
DriveExists (driveName) This method returns true if the drive letter exists otherwise it returns false.
FileExists (fileName) This method returns true if the file exists otherwise it returns false.
FolderExists (folderName) This method returns true if the folder exists otherwise it returns false.
GetAbsolutePathName
(path)
This method takes the path and returns the absolute path of the folder. Wildcard is accepted while calculating the path.
GetBaseName (filespec) This method just returns the name of the file specified in the specification by removing the path information.
GetDrive (drivespec) This method just returns the name of the drive as an object specified in the specification by removing the path information.
GetDriveName (drivespec) This method just returns the name of the drive specified in the specification by removing the path information.
GetExtensionName
(filespec)
This method returns the extension name for the file specified in the specification.
GetFile (filespec) This method return the file object specified in the file specification. File Specification may contain absolute or relative path.
GetFileName (pathspec) This method returns just the name of the file specified in the path specification.
GetFileVersion (filespec) This method returns the version of the file specified in the path specification.
GetFolder (folderspec) This method return the folder object specified in the file specification. Folder Specification may contain absolute or relative path.
GetParentFolderName
(pathspec)
This method returns just the name of the parent folder specified in the path specification.
GetSpecialFolder
(folderspec)
This method returns the Folder object with the below mentioned special permissions:
WindowsFolder (0)
SystemFolder (1)
TemporaryFolder (2)
GetTempName() This method generates a file randomly and returns the file name to perform some activities.
MoveFile (source,
destination)
Moves the file to the destination folder from source folder specified. If the destination folder already has a file with
the same name, WSH throws an error.
MoveFolder (source,
destination)
Moves the folder to the destination folder from source folder specified. If the destination folder already has a folder with
the same name, WSH throws an error.
OpenTextFile (filename,
iomode, create, format)
This method opens a file and return text as TextStreamObject. This can be used to read,write and
append to and from the file.
IOModes are:
ForReading (1)
ForWriting (2)
ForAppending (8)FileFormats are:
TristateFalse (0) to open it as ASCII,
TristateTrue (-1) to open it as Unicode
TristateUseDefault (-2) to open it using the system default format.

Drive Object

Drive object enables us to access the drives available in the system including network drives.

Drive Object Properties
Properties Comment
AvailableSpace Returns the available space inside the drive in bytes.
DriveLetter Returns the drive letter of the specified Drive
DriveType Returns the type of the drive
The type can be:
Unknown (0)
Removable (1)
Fixed (2)
Network (3)
CDRom (4)
RamDisk (5)
FileSystem Returns the file system of the Drive. The file systems can be:
FAT/NTFS/CDFS
FreeSpace Returns the free space available in the drive
IsReady Returns boolean True- drive is ready for operation and false is not ready for any operation.
Path Returns the path of the drive
RootFolder Returns boolean . True if the the current folder inside the drive is a Root folder.False otherwise
SerialNumber Returns the serial number of the drive. It is in decimal. This is to identify the disk volume.
ShareName Returns the network shared name of the drive.
TotalSize Returns the total size of the drive in bytes.
VolumeName Returns the Volume name of the drive. We can also set the name with the same property.

File Object

File Object lets us access the files available under a Folder. File Object provides the below properties and methods:

File Object Properties
Properties Comment
Name Sets or returns the name of the file.
Drive Returns the drive letter where the file resides.
DateLastModified It returns the Date and time when the file last modified.
DateLastAccessed It returns the Date and time when the file last accessed.
DateCreated It returns the Date and time when the file was created.
Attributes It returns various different attributes of a file like-
Normal (0)
ReadOnly (1)
Hidden (2)
System (4)
Volume (name) (8)
Directory (folder) (16)
Archive (32)
Alias (1024)
Compressed (2048)We can also set the following attributes:
ReadOnly
Hidden
System
Archive
ParentFolder Returns the parent folder as an Object for any file,folder.
Path Returns the absolute path of the file specified.
ShortName Returns the shortname or DOS style file name
ShortPath Returns the short path or DOS style file path name
Size Returns the size of the file.
Type Returns the type of the file.
File Object Methods
Method Comment
Copy (destinationfolderpath,
boolean overwrite)
It copies a specified file to the provided destination folder.Overwrite is a boolean argument
indicating overwrite is permitted if set as Yes.It will throw an error if there is a same file name
already exists and overwrite flag is false.
Delete (boolean force) Deletes a file forcefully if the force parameter is set as true.However force is an optional parameter.
By default it is false.The file will be deleted even if the read only attribute is set by the user.
Move(destinationFolder) Moves the file to the destination folder specified. If the destination folder already has a file with
the same name, WSH throws an error.
OpenAsTextStream(IOMode, FileFormat) This method opens a file and return text as TextStreamObject. This can be used to read,write and
append to and from the file.
IOModes are:
ForReading (1)
ForWriting (2)
ForAppending (8)FileFormats are:
TristateFalse (0) to open it as ASCII,
TristateTrue (-1) to open it as Unicode
TristateUseDefault (-2) to open it using the system default format.

Folder Object:

Folder Properties
Properties Comment
Name Sets or returns the name of the folder.
Drive Returns the drive letter where the folder resides.
Files Returns the File collection within the folder
IsRootFolder Returns boolean True or False. True if the folder is a Root folder.
DateLastModified It returns the Date and time when the folder was last modified.
DateLastAccessed It returns the Date and time when the folder was last accessed.
DateCreated It returns the Date and time when the folder was created.
Attributes It returns various different attributes of a folder like-
Normal (0)
ReadOnly (1)
Hidden (2)
System (4)
Volume (name) (8)
Directory (folder) (16)
Archive (32)
Alias (1024)
Compressed (2048)We can also set the following attributes:
ReadOnly
Hidden
System
Archive
ParentFolder Returns the parent folder as an Object
Path Returns the absolute path of the folder specified.
ShortName Returns the shortname or DOS style folder name
ShortPath Returns the short path or DOS style folder path name
Size Returns the size combined for files and folders inside of the folder.
Type Returns the type of the folder.
SubFolder Returns a collection of folders residing inside the specified folder.
Folder Methods
Method Comment
Copy (destinationfolderpath,
boolean overwrite)
It copies a specified folder to the provided destination folder.Overwrite is a boolean argument
indicating overwrite is permitted if set as Yes.It will throw an error if there is a same folder name
already exists and overwrite flag is false.
Delete (boolean force) Deletes a folder forcefully if the force parameter is set as true.However force is an optional parameter.
By default it is false.The file will be deleted even if the read only attribute is set by the user for any file.
Move(destinationFolder) Moves the folder to the destination folder specified. If the destination folder already has a file with
the same name, WSH throws an error.
CreateTextFile(fileName,
overwrite,unicode)
This method creates a text file in the specified folder with the specified fileName.

Overwrite is a boolean argument
indicating overwrite is permitted if set as Yes. The default overwrite parameter is false.

The last parameter is the indication of what format the text will be stored. Default for Unicode is false.If we set it as true the whole text will be placed in Unicode.

TextStream Object:

TextStream Object is responsible for sending and receiving the Streams to or from a file. TextStream object provides the below properties and methods:

TextStream Properties
Property Comment
Line It starts from line 1 and returns the current line number in the TextStream file.
Column It starts from character number 1 and returns the current character number as column from TextStream file.
AtEndOfLine Returns false if the file pointer has not reached to the end of the line
and returns true if the file pointer reached to the end of the line
AtEndOfStream Returns false if the file pointer has not reached to the end of the TextStream
and returns true if the file pointer reached to the end of the TextStream
TextStream Methods
Method Comment
WriteBlankLines (m) writes m new line characters to the specified file as a TextStream.
WriteLine (string) Writes a new line character to the specified file as a TextStream. The String argument is optional.
If provided the method will write to the file along with the new line character.
Write (string) Writes the provided String argument to the file.
SkipLine() Skips the next line while reading from a specified file.
Skip (numOfChars) Skips the specified number of characters while reading from a specified file.
ReadLine() Reads a line from the file specified.
ReadAll() Reads the whole file as a TextStream as a single String.
Read (numOfChars) Reads the specified number of characters while reading from a specified file.
Close () Closes a already opened file.

What is collection Object?

A collection is a set of Objects that stores data as a key value pair.Refer Dictionary Object for more details about collection. However we can not create our own collection objects.We need to use those which is supported by VBScript engine only.

Like Dictionary all collection objects provide two basic properties. They are as follows:

  1. Item
  2. Count

Collection supports Enumerations on the Item property by a For Each loop but does not support methods like Exists() or RemoveAll().

It is also good to have comments in order to work with complex coding during framework development.

To work with FSO we need to create an object like below and assign the object to an instance variable. This is the starting point to work with FileSystemObject.

dim oFSO
' creating the file system object
set oFSO = CreateObject ("Scripting.FileSystemObject") 

How to Create a new text file in UFT/QTP/VBScript?

' Parameters:
' FilePath - location of the file and its name
Function CreateFile (FilePath)
' varibale that will hold the new file object
dim NewFile
' create the new text ile
set NewFile = oFSO.CreateTextFile(FilePath, True)
set CreateFile = NewFile
End Function

How to check if a specific file exist or not in QTP/UFT/VBScript?

' Parameters:
' FilePath - location of the file and its name
Function CheckFileExists (FilePath)
' check if file exist
CheckFileExists = oFSO.FileExists(FilePath)
End Function

Another approach

Option Explicit 
Dim myobjFSO,myFolder,myFile,myResult 
Set myobjFSO=WScript.CreateObject("Scripting.FilesystemObject) 
Set myFolder=myobjFSO.GetFolder("D:\\test\") 
Set myobjFSO=Nothing
myResult=false
For Each myFile in myFolder.Files
  if UCase(myFile.Name)="Test.txt" 
     myResult=true 
     Exit For
  End If 
Next
Set myFolder=Nothing 
Set myFile=Nothing
If myResult then
 msgbox "The file.exists in D:/test/folder" 
else 
 msgbox"the file does not exist in D:/test/folder"
End If

Another upgraded approach

Option Explicit 
Dim myobjFSO 
Set myobjFSO=Wscript.CreateObject("Scripting.FilesystemObject")
If myobjFSO.FileExists("D:\\test\test.txt") then
  msgbox "test.txt is present in D:\\test" 
else 
  msgbox "test.txt is not present in D:\\test" 
End if 
Set myobjFSO= nothing

How to write data to file in QTP/UFT/VBScript?

Creating text file and writing in it is similar to reading the file.Again the text passed to the text file is TextStream object. Here we use CreateTextFile() method to create and write text into a file.CreateTextFile() creates a fresh new Text file for editing.However we can use overwrite flag as true to overwrite to an existing file.In that case we need to use OpenTextFile() method.

' Parameters:
' FileRef - reference to the file
' str - data to be written to the file
Function WriteToFile (byref FileRef,str)
' write str to the text file
FileRef.WriteLine(str)
End Function

How to read character by character from file in QTP/UFT/VBScript?

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("D:qtp.txt", 1)
Do Until objFile.AtEndOfStream
strCharacters = objFile.Read(1)
msgbox strCharacters
Loop

How to read line from file in QTP/UFT/VBScript?

' Parameters:
' FileRef - reference to the file
Function ReadLineFromFile (byref FileRef)
' read line from text file
ReadLineFromFile = FileRef.ReadLine
End Function

How to read Entire Text File using FSO in VBScript/UFT/QTP?

Reading Text file takes help of OpenTextFile() function. The function takes four inputs as arguments

They are:

  1. Which file to open?
  2. Why we are opening this file? Mode information

We have the following methods to read:

  1. ReadAll()- gets the entire file textStream into a String variable.
  2. Read()-gets one character at a time
  3. ReadLine()-gets line by line text from the file as a Stream.
' Parameters:
' FileRef - reference to the file
Function ReadTextFileTest(Filepath)
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f, Msg
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(Filepath, ForReading)
ReadTextFileTest = f.Readall()
End Function

another approach:


Dim fso,f
Set fso=createobject("Scripting.filesystemobject")
set f=fso.opentextfile("C:test.txt",1)
while f.atendofline<>true
s=f.readline()
msgbox s
wend
f.close
set f=nothing
set fso=nothing
 

another approach:


Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("D:test.txt", 1)
Do Until objFile.AtEndOfStream
strCharacters = objFile.Readline
msgbox strCharacters
Loop
 

Use of Do while is best , while reading from file as :

  • We are opening a file which has some lines in it.Do ensures that.
  • We can use a close method at the end which is a best practice.

How to close an opened file in UFT/QTP/VBScript?


' Parameters:
' FileRef - reference to the file
Function CloseFile (byref FileRef)
FileRef.close
End Function

How to open a specified file and returns an object that can be used to read from, write to, or append to the file in UFT/QTP/VBscript?


' Parameters:
' FilePath - location of the file and its name
' mode options are:
' ForReading - 1
' ForWriting - 2
' ForAppending - 8
Function OpenFile (FilePath,mode)
' open the txt file and retunr the File object
set OpenFile = oFSO.OpenTextFile(FilePath, mode, True)
End Function

How to copy file in VBScript/UFT/QTP?

For copying a file FileSystemObject provides a predefined function called CopyFile(). By default if Source File Path does not have drive information, CopyFile() will copy the file in the same directory.


' Parameters:
' FileRef - reference to the file
Sub FileCopy ( FilePathSource,FilePathDest,OverWriteFlag)
' copy source file to destination file
oFSO.CopyFile FilePathSource, FilePathDest,OverWriteFlag
End Function

It is always better to use a FileExists() method before performing any file related operations.

FilePathSource is the source file name along with the location. Like-“C:\Test\MyReport.html”

FilePathDest is the destination file name along with the location. like-“C:\Archive\MyReport.html”

OverWriteFlag is the boolean flag that enables or disables the overwrite mechanism while copying.(In case the file already exists). We need to provide true to overwrite and false for not overwriting.

Other strategies to Copy files?

  1. If we want to copy a specific type like .html or .xls in that case the FilePathSource(source of the file) parameter will be “C:\Test\*.html” and the FilePathDest (destination of the file) will be “C:\Archive\”.
  2. if we want to copy all files from one folder to another in that case the FilePathSource(source of the file) parameter will be “C:\Test\*.*” and the FilePathDest (destination of the file) will be “C:\Archive\”.
  3. If the files are getting generated using some system we can use Wildcarding using Regular Expression.

Note:

  • Wildcarding is not allowed in the destination folder specification
  • We need to add the tailing backslash in the destination path just to tell WSH that it is a folder.

How to delete a file in UFT/QTP/VBScript?


' Parameters:
' FileRef - reference to the file
Sub FileDelete ( FilePath)
oFSO.DeleteFile ( FilePath)
End Function

How to create Folder if Not Exists in UFT/QTP/VBscript?

There are two ways we can create a folder

  • Using CreateFolder() method
  • Using Collection’s Add method
Using CreateFolder() method:

Function ReportFolderStatus(fldr)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If Not (fso.FolderExists(fldr)) Then
fso.CreateFolder(fldr)
End If
End Function
ReportFolderStatus("C:\Temp")
 
Using Collections Add() method

Option Explicit
Function ReportFolderStatus(fldr,folderToCreate)
Dim fso
Dim myObjFolder
Set fso = CreateObject("Scripting.FileSystemObject")
Set myObjFolder=fso.getFolder(fldr)
If Not (fso.FolderExists(fldr&"\&folderToCreate)) Then
myObjFolder.SubFolders.Add(folderToCreate)
End If
End Function
ReportFolderStatus("C:\Temp","Test")
 

How to delete a Folder in UFT/QTP/VBscript?


//direct delete
Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.DeleteFolder("E:\FSO")
//using function
Function deleteFolder(sFolderName)
Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.DeleteFolder(sFolderName)
Set oFSO=nothing
End Function
call deleteFolder("E:\Temp")

How to copy a Folder in UFT/QTP/VBscript?

Copy a folder is complex activity as inside the folder there can be files and folders.


//direct method
Set oFSO=createobject("Scripting.Filesystemobject")
oFSO.CopyFolder "E:\test", "C:\jvr",true
//using function
Function copyFolder(folderSrc,folderDest)
Set oFSO=createobject("Scripting.Filesystemobject")
oFSO.CopyFolder folderSrc,folderDest,boolflag
End Function
call copyFolder "E:\test", "C:\jvr",true

It is same as copy a file and the argument is pretty much same.

It is always better to use a FileExists() method before performing any file related operations.

folderSrc-is the source file name along with the location. Like-“C:\Test\”

folderDest-is the destination file name along with the location. like-“C:\Archive\”

boolflag-is the boolean flag that enables or disables the overwrite mechanism while copying.(In case the folder is already exists). We need to provide true to overwrite and false for not overwriting.

How to Count Number of Lines in text file in VBscript/UFT/QTP?


Function NumberOfLines(FileName)
i = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(FileName, ForReading)
Do Until objTextFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objTextFile.ReadLine
i = i +1
Loop
NumberOfLines = UBound(arrFileLines)
objTextFile.Close
End Function
msgbox NumberOfLines("C:Tempmyfile.txt")

How to get Collection(names) of Subfolders in a Folder in QTP/UFT/VBScript?


Dim a,b, c, d, e
Set a = CreateObject("Scripting.FileSystemObject")
Set b = a.GetFolder("C:\Animesh")
Set c = b.SubFolders
For Each d in c
e=e&d.name&vbnewline
Next
msgbox e
 

How to Count the Number of Files in a Folder in QTP/UFT/VBScript?


iFileCount = 0
Set objFileSysOb = CreateObject("Scripting.FileSystemObject")
Set colFolderName = objFileSysOb.GetFolder("C:Automation") ' Folder Path
Set vFiles =colFolderName.Files
For each vFileItem in vFiles
msgbox vFileItem
iFileCount = iFileCount + 1
Next
msgbox iFileCount
 

How to return a collection of Disk Drives in QTP/UFT/VBScript?


Set oFSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = oFSO.Drives
For Each oDrive in colDrives
MsgBox "Drive letter: " & oDrive.DriveLetter
Next
 

How to calculate available space on a Disk Drive in QTP/UFT/VBScript?


Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oDrive = oFSO.GetDrive("C:")
MsgBox "Available space: " & oDrive.AvailableSpace
 

How to check if a File is available or not, if available delete the File in QTP/UFT/VBScript?


strDirectory="E:"
strFile="test.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strDirectory & strFile) Then
Set objFile = objFSO.Getfile(strDirectory & strFile)
objFile.delete ()
End if

What is not supported by FSO?

FSO does not support to inserting data at the begining of an existing file or adding some data in the middle.

In HTML Reporting we need these tasks to be accomplished, so we need to break the task into two parts.

  1. Read the existing data into the String
  2. Write new Strings
  3. Merge and put in a textfile.
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 25
  • 34
  • 12
  • 23
  •  
  •  
  •  
  •  
  •  
  •  
    94
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here