I have a process which opens a Word doc using DocumentBuilder, gets the contents using GetText() and updates a database record.
I am seeing an extra form feed character in the updated data. If I watch this in debug, I can see that there is an ASCII 12 as the last character. If I open the Word doc in binary mode in TextPad, there are two “0D” values immediately following my last visible character.
Is there something about GetText that adds the ASCII 12?
Here is the meat of my code:
string[] fileEntries = Directory.GetFiles(txtChargeLangPath.Text, "*_LANGUAGE.DOC");
foreach (string fileName in fileEntries)
{
langDoc = new Document(fileName);
chargeLanguage = langDoc.GetText();
lastChar = chargeLanguage[chargeLanguage.Length - 1];
lastCharInt = lastChar;
MessageBox.Show(lastCharInt.ToString()); // Shows "12"
myUpdateCommand.CommandText = "Update tblCsCharge Set ChargeLanguage = '" + chargeLanguage.Substring(0, chargeLanguage.Length - 1) + "' Where FileNumber = '" + fileNumber + "' and CountNumber = " + countNumber;
myUpdateCommand.ExecuteNonQuery();
}