public static void Merge(string inputfile, string inputpath, string outputpath, string exten)
{
//string outPath = inputpath;
string[] tmpFiles = Directory.GetFiles(inputpath, inputfile + "*" + exten);
FileStream outputFile = new FileStream(outputpath, FileMode.OpenOrCreate, FileAccess.Write);
string prevFileName = "";
foreach (string tempFile in tmpFiles)
{
string fileName = Path.GetFileNameWithoutExtension(tempFile);
string baseFileName = fileName;
string extension = Path.GetExtension(fileName);
int bytesRead = 0;
byte[] buffer = new byte[1024];
FileStream inputTempFile = new FileStream(tempFile, FileMode.OpenOrCreate, FileAccess.Read);
while ((bytesRead = inputTempFile.Read(buffer, 0, 1024)) > 0)
outputFile.Write(buffer, 0, bytesRead);
inputTempFile.Close();
prevFileName = baseFileName;
}
outputFile.Close();
}