日期:2014-05-18 浏览次数:21072 次
public void CompileProject() { Process helpCompileProcess = new Process(); //创建新的进程,NDOC采用Process启动HHC.EXE来Compile一个CHM文件 try { ////判断文件是否存在并不被占用 try { string path = _chmFile; //chm生成路径 if (File.Exists(path)) { File.Delete(path); } } catch { throw new Exception("文件被打开!"); } ProcessStartInfo processStartInfo = new ProcessStartInfo(); processStartInfo.WindowStyle = ProcessWindowStyle.Hidden; processStartInfo.FileName = hhcFile; //调入HHC.EXE文件 processStartInfo.Arguments = "\"" + Path.GetFullPath(GetPathToProjectFile()) + "\"";//获取空的HHP文件 helpCompileProcess.StartInfo = processStartInfo; //开始生成.... helpCompileProcess.Start(); helpCompileProcess.WaitForExit(); //组件无限期地等待关联进程退出 if (helpCompileProcess.ExitCode == 0) { MessageBox.Show(new Exception().Message); } } finally { helpCompileProcess.Close(); } } public void OpenProjectFile() { FileStream fs = new FileStream(GetPathToProjectFile(), FileMode.Create); streamHtmlHelp = new System.IO.StreamWriter(fs, System.Text.Encoding.GetEncoding("GB18030")); streamHtmlHelp.WriteLine("[FILES]"); } public void AddFileToProject(string filename) { streamHtmlHelp.WriteLine(filename); } public void CloseProjectFile(string title) { streamHtmlHelp.WriteLine(); streamHtmlHelp.WriteLine("[OPTIONS]"); streamHtmlHelp.WriteLine("Title=" + title); streamHtmlHelp.WriteLine("Compatibility=1.1 or later"); streamHtmlHelp.WriteLine("Compiled file=" + GetCompiledHtmlFilename()); //chm文件名 streamHtmlHelp.WriteLine("Contents file=" + GetContentsHtmlFilename()); //hhc文件名 streamHtmlHelp.WriteLine("Default topic=" + _defaultTopic); //默认页 streamHtmlHelp.WriteLine("Display compile progress=No"); //是否显示编译过程 streamHtmlHelp.WriteLine("Language=0x804 中文(中国)"); //chm文件语言 streamHtmlHelp.WriteLine(); streamHtmlHelp.WriteLine("[INFOTYPES]"); streamHtmlHelp.Close(); }
------解决方案--------------------
http://www.xdesigner.cn/chmbuilder/chmbuilder.rar