Answer Posted / yogesh
'MERGE CONTENTS OF TWO FILE
Option Explicit
Const conForReading = 1
Const ForAppending = 8
Dim objFSO: Set objFSO = CreateObject
("Scripting.FileSystemObject")
Dim file1,file2,file3,contents1,contents2
Dim strfile1,strfile2,strfile3 'Declare
variables
strfile1=inputbox("Enter path of Source file 1","Copy file
utility"," ")
strfile2=inputbox("Enter path of Source file 2","Copy file
utility"," ")
strfile3=inputbox("Enter path of To Create Target
file","Copy file utility"," ")
Set file1 = objFSO.OpenTextFile(strfile1, conForReading,
False)
Set file2 = objFSO.OpenTextFile(strfile2, conForReading,
False)
Set file3 = objFSO.CreateTextFile(strfile3, ForAppending,
True)
'Set Objects
contents1 = file1.ReadAll
contents2 = file2.ReadAll
'Read file contents
file1.Close
file2.Close
'Close file after use
file3.WriteLine(contents1)
file3.writeLine(contents2)
'Write contents to file
file3.Close
'Close file after use
Set file1 = Nothing
Set file2 = Nothing
Set file3 = Nothing
Set objFSO = Nothing
'freezing memory of objects
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Are the variables argc and argv are local to main?
Explain how do you list a file’s date and time?
What is meant by inheritance?
Explain threaded binary trees?
Can a local variable be volatile in c?
Write a program to identify if a given binary tree is balanced or not.
Do character constants represent numerical values?
What is the best organizational structure?
Why c is called object oriented language?
What is the scope of local variable in c?
Define VARIABLE?
Explain how do you convert strings to numbers in c?
Differentiate between a for loop and a while loop? What are it uses?
Explain what is the benefit of using #define to declare a constant?
What does 2n 4c mean?