In the old dos days you could combine 2 files as save to a third file:
copy file1 + file2 file3
It still works in a dos shell.
I did this:
Shell("copy " & file1 & " + " & file2 & " " & file3)
I got an error that file3 cannot be found. I know it doesn't exist I want to create it. So I created a bat file:
copy %1 + %2 %3
and called it as such:
Shell("ccopy " & file1 & " " & file2 & " " & file3)
I still get the error that file3 cannot be found.
First I don't see how it can tell from the shell that file3 is a file.
How do I do this otherwise
Do I have to create a blank file before calling it

Merge files
Programm3r
I think to use a .NET code is better than using shell command, because this wouldn't work in windows 98 as there's no cmd.exe!!!!
I think if you use a code like that whar rkimble written but in a binary format will be better.
Mike Fulkerson
Here's the reason:
The copy command is an internal DOS command and can't be directly executed because there's no file named copy.exe or copy.com...
Call Shell("cmd /c Copy " & file1 & " + " & file2 & " " & file3,vbHide)
this will work for Windows Xp and copies the two files.
Note that: Command copies only the first file and doesn't copy the others , really i don't know why but cmd.exe does the whole task.
the argument /c executes a Dos Internal Command then terminates.
To know more about copy just open cmd.exe then type copy /
Best regards,
Amr Ouf
Rajesh batchu
Use system.diagnostic.process.start and not shell.
Its a lot more flexible and a .net managed code class.
Process.Start(
"cmd", "/c Copy c:\test1.txt + c:\test2.txt c:\test3.txt")Ghoort
Using external command to run is an operating system dependant and there's no guarantee for the file is generated or written successfull, so i recommend to use this funciton instead.
Johan Sörlin
You'll need to read both files in, combine them, and then write them back. An example might be:
Private Sub MergeFiles(ByVal file1 As String, ByVal file2 As String, ByVal outputfile As String)
FileIO.FileSystem.WriteAllText(outputfile, FileIO.FileSystem.ReadAllText(file1), True)
FileIO.FileSystem.WriteAllText(outputfile, FileIO.FileSystem.ReadAllText(file2), True)
End Sub
hrubesh
Here's a function that can append two files in binary mode you can do two calls to this function to append 2 files on a single file.
for example:
Call AppendFile("c:\2.ini", "C:\3.txt")End Sub
Hope this can help!
Best Regards,
kiwicoder2
However, it will only copy the first file to the third file using either of the two shell commands. In dos the copy copies file1 and file2 to file3. In the shell command it doesn't.