using Stream CopyTo() without overwriting existing output file
c#, file, filestream
Solution
Instead of `OpenWrite` use `Open` and pass in `FileMode.Append`:
using (var output = File.Open(outputFile, FileMode.Append))
This will append the output to the end of the file.
Problem
How do I use the Stream CopyTo method without overwriting the existing output file? ``` public void MergeAndDeleteFiles(string outputFile, IEnumerable<string> inputFiles) { using (var output = File.OpenWrite(outputFile)) { foreach (var inputFile in inputFiles) { using (var input = File.OpenRead(inputFile)) { input.CopyTo(output); } } } } ``` The above method overwrites the outputFile for some reason? DO i need to set the position of the output file before using the CopyTo method?