using Microsoft.Office.Interop.Word;

namespace Sex
{
    public partial class Sex : System.Web.UI.Page
    {
        // experimental, does not work due to permission errors on interop.dll even if all rights are given for "everyone"
        // http://support.microsoft.com/?id=304662 Read Word Document
        public string readFileContent(string path)
        {

            // ApplicationClass wordApp = new ApplicationClass();

            Application wordApp = new Application();
            object file = path;
            object nullobj = System.Reflection.Missing.Value;
            Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(
            ref file, ref nullobj, ref nullobj,
            ref nullobj, ref nullobj, ref nullobj,
            ref nullobj, ref nullobj, ref nullobj,
            ref nullobj, ref nullobj, ref nullobj,
            ref nullobj, ref nullobj, ref nullobj, ref nullobj);
            doc.ActiveWindow.Selection.WholeStory();
            doc.ActiveWindow.Selection.Copy();
            string sFileText = doc.Content.Text;
            doc.Close(ref nullobj, ref nullobj, ref nullobj);
            wordApp.Quit(ref nullobj, ref nullobj, ref nullobj);
            return sFileText;
        }
    }
}