I am developing a windows service in C# using visual studio 2010 for reading emails that have .doc, .docx, .rtf, .txt attachment files. I am using the Spire.Doc Pro Edition for .NET component to convert these file to native text . the .doc and .docx files were converted succefully but .rtf and .txt did not converted at all .
- Code: Select all
switch (strFileExtension)
{
case "docx":
document.LoadFromFile(MailAttachmentPath + strNewFileName + "." + strFileExtension, FileFormat.Docx);
document.SaveToFile(MailAttachmentPath + strFileNameWithoutExtension + ".txt", FileFormat.Txt);
document.Close();
break;
case "doc":
document.LoadFromFile(MailAttachmentPath + strNewFileName + "." + strFileExtension, FileFormat.Doc);
document.SaveToFile(MailAttachmentPath + strFileNameWithoutExtension + ".txt", FileFormat.Txt);
document.Close();
break;
case "rtf":
document.LoadFromFile(MailAttachmentPath + strNewFileName + "." + strFileExtension, FileFormat.Rtf);
document.SaveToFile(MailAttachmentPath + strFileNameWithoutExtension + ".txt", FileFormat.Txt);
document.Close();
break;
case "txt":
document.LoadFromFile(MailAttachmentPath + strNewFileName + "." + strFileExtension, FileFormat.Txt);
document.SaveToFile(MailAttachmentPath + strFileNameWithoutExtension + ".txt", FileFormat.Txt);
document.Close();
break;
}
In case of case "txt" when the file contains text like :
ãßÊÈ æßÇáÉ ÇáÃäÈÇÁ ÇáÓÚæÏíÉ ÈÇáÞÇåÑÉ íÍííßã æíÈÏà ãÚßã ÈËå áåÐÇ Çáíæã ÇáÃÑÈÚÇÁ ÇáãæÇÝÞ 13 ÑÌÈ 1432åÜ ãßÊÈ æßÇáÉ ÇáÃäÈÇÁ ÇáÓÚæÏíÉ ÈÇáÞÇåÑÉ íÍííßã æíÈÏà ãÚßã ÈËå áåÐÇ Çáíæã ÇáÃÑÈÚÇÁ ÇáãæÇÝÞ 13 ÑÌÈ 1432åÜ /1/ ÇåÊãÇãÇÊ ÇáÕÍÝ ÇáãÕÑíÉ ÇáÞÇåÑÉ 13 ÑÌÈ 1432åÜ ÇáãæÇÝÞ 15 íæäíæ 2011ã æÇÓ ÇÓÊÍæÐ äÈà ÊÍÞíÞ äíÇÈÉ Ããä
i have the exception :
[color=#FF0040]System.IndexOutOfRangeException was unhandled Message=Index was outside the bounds of the array. Source=Spire.Doc[/color]
So what is the problem ?
Thanks