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
What is #ifdef ? What is its application?
What is assignment operator?
Not all reserved words are written in lowercase. TRUE or FALSE?
How can you return multiple values from a function?
What is the purpose of main( ) in c language?
What is the most efficient way to count the number of bits which are set in an integer?
What is the difference between class and object in c?
What are global variables and how do you declare them?
What is the difference between c and python?
Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?
Do character constants represent numerical values?
What are the differences between new and malloc in C?
How variables are declared in c?
Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?
What are extern variables in c?