Exemple #1
0
        private void btn_OpenA_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                webBrowser1.Navigate("about:blank");
                tbd_filename1.Text = openFileDialog1.FileName;
                string sFilePath = openFileDialog1.FileName;

                if (SysUtil.GetFileExt(sFilePath) == ".doc")
                {
                    WordHelp helper = new WordHelp();
                    helper.Open(sFilePath);
                    string htmlFilePath = System.Windows.Forms.Application.StartupPath + "/TEMP/temp_" + DateTime.Now.Ticks + ".html";
                    helper.SaveAsHtml(htmlFilePath);

                    helper.Quit();
                    this.labelItem1.Text = "转换中";
                    Thread.Sleep(3000);

                    this.labelItem1.Text = "转换完毕";
                    // webBrowser1.Navigate(System.Windows.Forms.Application.StartupPath + "/ckeditor/samples/editor.html");

                    StreamReader reader = new StreamReader(htmlFilePath, Encoding.GetEncoding("gb2312"), true);


                    string html = reader.ReadToEnd();

                    html = html.Substring(html.IndexOf("punctuation'>"), html.Length - html.IndexOf("punctuation'>"));
                    html = html.Substring(13, html.IndexOf("</body>") - 12);

                    webBrowser1.Navigate(this.getEditorHTML(html));
                }
                else if (SysUtil.GetFileExt(sFilePath) == ".html")
                {
                    webBrowser1.Navigate(sFilePath);
                }

                a_isOpen = true;
            }
        }