Merge Files in C#.net

Naraayanan
Posted by Naraayanan under C# category on | Points: 40 | Views : 2308
These functions are merged a files in the Folder from One location to another location.
public  void mergefiles(string inputFile, string outputFileName)
{
#region get PCL file from inputFile
string[] tmpfiles = Directory.GetFiles(inputFile, "*.pcl");
#endregion get PCL file from inputFile
FileStream output = new FileStream(outputFileName, FileMode.Create);
#region start Processing
foreach (string tempInput in tmpfiles)
{
FileStream inputfiles = new FileStream(tempInput, FileMode.Open);
CopyStream(output, inputfiles);
}
#endregion start Processing

MessageBox.Show("Done");

}

void CopyStream(Stream destination, Stream source)
{
int count;
byte[] buffer = new byte[BUFFER_SIZE];

while ((count = source.Read(buffer, 0, buffer.Length)) > 0)
destination.Write(buffer, 0, count);
}

Comments or Responses

Login to post response