10 Jul 2008 - 05:48:10 pm
What is FSO?
FSO stands for File System Object. This is used to support text file creation and manipulation through the TextStream object and is contained in the Scripting type library (Scrrun.dll)The FSO Object Model has a rich set of properties, methods and events to process folders and files.
How to create a file?
We first create a FSO object using CreateObject and then create a text file using CreateTextFile.For Example: Suppose you want to create a file called "test.txt" located in C:
Dim fso, file, file_location
file_location = "C:file_location"
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set file = fso.CreateTextFile(file_location, True) // True--> file is to be overwritten if it already exists else false We would use the same example for the rest of this post.
How to open a file?
Set file= fso.OpenTextFile("C:file_location", ForWriting, True)
//2nd argument can be ForReading, ForWriting, ForAppending
//3rd argument is "True"
if new file has to be created if the specified file doesn’t exist else false, blank signify false.
How to read content from a file?
Use ReadLine() method
For example:
Set file= fso.OpenTextFile("C:file_location", ForReading, True)
//2nd argument should always be "ForReading" in order to read contents from a file
Do while file.AtEndofStream <> True
data = file.ReadLine()
msgbox dataLoop
How to write content to a file?
You can use Write() or WriteLine() Methods to write text into a file. The difference between the Write() and WriteLine() Method is that the latter automatically inserts a new line character while the former doesn’t insert a new line character.
For example:
Set file= fso.OpenTextFile("C:file_location", ForWriting, True) //
2nd argument should always be "ForWriting" in order to write contents to a filefile.Write("This is a place to get all your qtp") file.Write("questions and answers solved.")//Output will be: This is a place to get all your qtp questions and answers solved. whilefile.WriteLine("This is a place to get all your qtp") file.Write("questions and answers solved.")//Output will be: This is a place to get all your qtpquestions and answers solved.
How to delete content?
Use DeleteFile() method to delete a file from a particular locationFoe Example:
file_location = "C:file_location"
Set fso = CreateObject(“Scripting.FileSystemObject”)
fso.DeleteFile(file_location
FSO stands for File System Object. This is used to support text file creation and manipulation through the TextStream object and is contained in the Scripting type library (Scrrun.dll)The FSO Object Model has a rich set of properties, methods and events to process folders and files.
How to create a file?
We first create a FSO object using CreateObject and then create a text file using CreateTextFile.For Example: Suppose you want to create a file called "test.txt" located in C:
Dim fso, file, file_location
file_location = "C:file_location"
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set file = fso.CreateTextFile(file_location, True) // True--> file is to be overwritten if it already exists else false We would use the same example for the rest of this post.
How to open a file?
Set file= fso.OpenTextFile("C:file_location", ForWriting, True)
//2nd argument can be ForReading, ForWriting, ForAppending
//3rd argument is "True"
if new file has to be created if the specified file doesn’t exist else false, blank signify false.
How to read content from a file?
Use ReadLine() method
For example:
Set file= fso.OpenTextFile("C:file_location", ForReading, True)
//2nd argument should always be "ForReading" in order to read contents from a file
Do while file.AtEndofStream <> True
data = file.ReadLine()
msgbox dataLoop
How to write content to a file?
You can use Write() or WriteLine() Methods to write text into a file. The difference between the Write() and WriteLine() Method is that the latter automatically inserts a new line character while the former doesn’t insert a new line character.
For example:
Set file= fso.OpenTextFile("C:file_location", ForWriting, True) //
2nd argument should always be "ForWriting" in order to write contents to a filefile.Write("This is a place to get all your qtp") file.Write("questions and answers solved.")//Output will be: This is a place to get all your qtp questions and answers solved. whilefile.WriteLine("This is a place to get all your qtp") file.Write("questions and answers solved.")//Output will be: This is a place to get all your qtpquestions and answers solved.
How to delete content?
Use DeleteFile() method to delete a file from a particular locationFoe Example:
file_location = "C:file_location"
Set fso = CreateObject(“Scripting.FileSystemObject”)
fso.DeleteFile(file_location
Syndication
2010-03-13 @ 06:52:43 pm
by Bobbi29Ramsey
A student, who gets know a ...
2010-03-13 @ 01:51:36 pm
by FernandezMitzi
mbt sale ,mbt walking ...
2010-03-13 @ 12:46:50 pm
by mbt
mbt sale promotion, mbt ...
2010-03-13 @ 12:43:48 pm
by mbt
mbt shoes uk direct,mbt ...
2010-03-13 @ 12:41:59 pm
by mbt
mbt sale, mbt lami ...
2010-03-13 @ 12:39:39 pm
by mbt
mbt shoes sale promotion, ...
2010-03-13 @ 12:36:30 pm
by mbt
ghd hair straightenersand CHI ...
2010-03-13 @ 08:32:36 am
by GHD
ghd hair straighteners and
2010-03-13 @ 08:31:02 am
by GHD
ghd and CHI Flat ...
2010-03-13 @ 08:30:16 am
by GHD
ghd hair straighteners and
2010-03-13 @ 08:29:45 am
by GHD
ghd hair straighteners and
2010-03-13 @ 08:29:12 am
by GHD
CHI Flat iron and
2010-03-13 @ 08:28:25 am
by GHD
ghd hair straighteners and
2010-03-13 @ 08:27:27 am
by GHD
ghd is a world famous ...
2010-03-13 @ 08:26:33 am
by GHD