In my application, I want to read a document file (.doc or .odt or .docx) and store that text in a string. For that, I am using the code below:
string text;
using (var streamReader = new StreamReader(@"D:\Sample\Demo.docx", System.Text.Encoding.UTF8))
{
text = streamReader.ReadToEnd();
}
But I am unable to read or copy proper text, as it shows like:
PK�����!��x%���E���[Content_Types].xml �(������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������IO�0��H���W��p@5��r�Jqv�Ij/�ۿg�%j��)P.���y��tf�N&�QY����0��T9���w,� L!jk gs@�л���0!����Bp�����Y�VJ�t�+���N�Kk�����z�'(Ÿ��/I��X�|/F�L騏��^��w$¹ZIho|b��tŔ�r����+?�W��6V�7*�W$}�ë�DΧ���r�i��q�=��,��Fݜ��t�5+Z(��?�a�z���i�[!0�k��,}O��Ta�\� �m?�i�|���ж�AT�SB�;'m;y\9�"La��o� %��@k8��?,Fc� hL_\��̱�9I����!�=��m��TT���|P�̩}}�$�|��� ��=�|��}�����PK��
How can I read or copy text from document files?