I have created a process which reads a "template" text file and then based on the String.Format requirements uses the tokens to place my custom text in.

So, everything works, but the process is slow.

The template file can have about 500-1000 lines; I am looking for a way to speed this process up.

Any ideas?

Here is my code below:

```
templateFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", "");
templateFilePath += "\\Templates\\TemplateFile.txt";
tempRequestFilePath = System.IO.Path.GetTempPath();
tempRequestFilePath += Guid.NewGuid();
Directory.CreateDirectory(tempRequestFilePath);
responseFileToWrite = tempRequestFilePath + "\\" + Path.GetFileNameWithoutExtension(zipMergeFilePath) + ".RSP";
if (!File.Exists(templateFilePath))
{
    return false;
}
templateString = System.IO.File.ReadAllText(templateFilePath);
currentRecordNumber = 1;
for (int i = 0; i < createToProcess.rtfText.Lines.Length; i++)
{
    if (createToProcess.rtfText.Lines[i].Contains("TAG ID:"))
    {
        string currentTagID = createToProcess.rtfText.Lines[i].Substring(9, 11).Trim();
        string currentCustomerNumber = createToProcess.rtfText.Lines[i].Substring(25, 12).Trim();
        string currentTaxPeriod = createToProcess.rtfText.Lines[i].Substring(42, 8).Trim();
        string currentCustomerPhoneNumber = createToProcess.rtfText.Lines[i].Substring(55, 9).Trim();
        DateTime datePurchases = (DateTime.Now).AddDays(-7);
        DateTime dateReceived = (DateTime.Now).AddYears(10);
        DateTime dateModified = (DateTime.Now).AddYears(-1);
        string currentResearchCreateRecord = String.Format(templateString,
            currentTagID.PadRight(6),
            currentCustomerNumber.PadRight(12),
            currentTaxPeriod.PadRight(6),
            currentCustomerPhoneNumber.PadRight(8),
            datePurchases.Month.ToString("00") + datePurchases.Day.ToString("00") + datePurchases.Year.ToString("0000"),
            "RecordNo: " + currentRecordNumber.ToString(),
            dateReceived.Month.ToString("00") + dateReceived.Day.ToString("00") + dateReceived.Year.ToString("0000"),
            dateModified.Month.ToString("00") + dateModified.Day.ToString("00") + dateModified.Year.ToString("0000")
            );
        System.Windows.Forms.Application.DoEvents();
        File.AppendAllText(responseFileToWrite, currentResearchCreateRecord);
        currentRecordNumber += 1;
    }
}
using (ZipFile currentZipFile = new ZipFile())
{
    currentZipFile.AddFile(responseFileToWrite, "");
    currentZipFile.Save(zipMergeFilePath);
}
return true;

```