用C#实现将HTML文件转换为CHM文件(转)
这些天因为工作需要,要将一些html文件转换为chm文件,当然是需要和程序结合在一起。
后来找到NDoc,里头有一段代码是相关的,于是开始分析代码,写完之后,总结:主要是利用微软的hhc.exe来编译html文件,程序需要将具体的数据写入hhp和hhc文件。
主要代码如下:
复制C#代码保存代码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;
//
相关文档:
java 代码
package util;
import java.io.UnsupportedEncodingException;
import dao.socket.OperType;
public class Encrpt {
private String key;
public Encrpt() {
this("sitow");
}
public Encrpt(String key) {
this.key = key;
}
private ......
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;namespace md5
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(UserMd5("8"));
Console.WriteLine(GetMd5Str("8"));
}
/**//// <summary>
/// MD5 16位加密
......
private void Create_Pz(string Sourcename)
{
string OutMsg;
SqlParameter[] sortPara = { new SqlParameter("@ps_IsType", Pz ......
非常简单,在C#中只需要在类的方法的上方敲三下"/"就自动帮你添加相关的代码,你只要按着填写就可以了,而Java则是输入"/**",它也会自动形成相关代码,具体代码如下:
C#
/// <summary>
/// 在此填写总体描述
///</summary>
/// <param name="name">这里填写参数name的描述</param>
public string ......