vbMark said:
I could not figure out how to use FIleStream.
I checked out the code on that site and was thoroughly confused.
In what way? Which bit was confusing?
I tried doing this:
StreamReader sr = new StreamReader("2.pdf");
StreamWriter sw = new StreamWriter("1.pdf",true);
Bad idea - StreamReaders are for *text* - PDFs are binary files.
Here's a program to append one file onto another - the first command
line parameter is the file to be appended to, the second command line
parameter is the file to append. There's currently no parameter
checking, of course...
using System;
using System.IO;
public class AppendFile
{
static void Main(string[] args)
{
using (Stream original = new FileStream(args[0],
FileMode.Append))
{
using (Stream extra = new FileStream(args[1],
FileMode.Open,
FileAccess.Read))
{
byte[] buffer = new byte[32*1024];
int blockSize;
while ( (blockSize = extra.Read
(buffer, 0, buffer.Length)) > 0)
{
original.Write (buffer, 0, blockSize);
}
}
}
}
}