Welcome to pickSourcecode.com Login | Register    
pickZy.com
 Home  | search  | games  | General  | C  | C++  | Java  | Php  | Networking  | Visual Basic  | VC++  | Win32  | MFC  | JavaScript  | Jobs  | JavaScript  | Post jobs
QTP : VBScript to create a file       Share
2010-03-11 |  MalathiVanaraj  | Viewed: 2178  |    0

QTP : VBScript to create a file

File System Object model is:


Drive
|
Folder
|
File
|
Textstream

or

Drive
|
Folder
|
Folders
|
File
|
Files
|
Textstream

These objects have methods and properties. With these  you can obtain and work with the information about drives, folders, files etc like creating a new file, opening a file, writing into a file and much more.


Here we will see a very simple example how to create a text file from within QTP.


Dim fso, new_file
Set fso = createobject("scripting.filesystemobject") // an instance of filesystemobject is being created here. After an instance (fso) is created then we can use the methods (like createtextfile, CreateFolder etc) with that objects instance.
Set new_file = fso.createtextfile("c:\testfile.txt", True) //createtextfile is a
method to create a file and after creating a file it returns a TextStream object
that can be used to read from or write to the file.
new_file.writeline("hello world!")
new_file.close

Just write the above text in the expert view of a new blank test and run it. A new text file (testfile.txt) will be created with "hello world!" written in it.


Try to change the extention of testfile.txt to testfile.doc and see what happens.


Comments:





Submit comment's

Type:

User Comment's:

Submitted By:
Name: sudha
Prof: Software
Tech: Php ,C
Send Mail: mail2sudha2



Related topics
There is a 50m long army platoon marching ahead. .? - Puzzle
Mr. Bajaj's mother is an Engineer and another is a Doctor. - puzzle
Three men - Sam, Cam and Laurie - are married to Carrie, Billy and Tina? - Puzzle
There are 3 persons X, Y and Z. On some day, X lent tractors to Y and Z as many as they had. .? - Puzzle
A certain street has 1000 buildings. A sign-maker is contracted to number the houses from 1 to 1000..? - Puzzle
DON T EAT TOO MUCH RICE
List of Different Types of Doctors
How to write cover letters
Great Tips for Great Resume
Old carpenter -Story
COIMBATORE ENGINEERING COLLEGES LIST AND ITS SITES
Job Openings in HAL (Especially disabled people.. there is special quota...)
To Reduce Tension in Our Life
Healthy tips
Keep Walking.....-Health tips

Related References
how to draw hexagon diagram? - objective c
to return the key board
recursively delete subdirectories

Web site contents © Copyright 2007, All rights reserved.
Help | Terms and Conditions | Privacy Policy | About Us