//根据word文档生成对应的html文档, 并存储到指定位置 private bool DeviceBaseGenerateHtmlByWord(string wordFullPath) { if (File.Exists(wordFullPath)) //若所选中的文件存在 { //获取文件对应的HTML所在目录----目录名+\\+不带后缀的文件名+"-html" string htmlDirPath = Path.GetDirectoryName(wordFullPath).Replace("SrcFiles", "HtmlFiles") + "\\" + Path.GetFileNameWithoutExtension(wordFullPath) + "-html"; //获取对应的html文件的文件名 string htmlFilePath = htmlDirPath + "\\" + Path.GetFileNameWithoutExtension(wordFullPath) + ".html"; if (Directory.Exists(htmlDirPath)) //若存放HTML文件的目录存在 { if (File.Exists(htmlFilePath)) //若Html文件存在, 则显示出来 { webBrowserDeviceBase.Navigate(htmlFilePath); //显示到WebBrowser中 } else //若Html文件不存在, 则创建 { try { AppUtil.ConvertDocToHtml(wordFullPath, htmlFilePath); //创建Html文件 return(true); } catch (Exception ex) { Console.WriteLine(ex.Message); log.Info(AppUtil.getExceptionInfo(ex)); } } } else //若存放HTML文件的目录不存在, 则创建目录 { try { Directory.CreateDirectory(htmlDirPath); AppUtil.ConvertDocToHtml(wordFullPath, htmlFilePath); //创建Html文件 return(true); } catch (Exception ex) { Console.WriteLine(ex.Message); log.Info(AppUtil.getExceptionInfo(ex)); } } } return(false); }