求助:htm转mht

calebgch 2008-03-11 08:00:44
怎么用C/C++把一个htm文件转成mht?
要求把.htm一起的文件夹里面的也要加到mht里面
怎么做?
...全文
326 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
calebgch 2008-03-14
  • 打赏
  • 举报
回复
我再细说一下,现在a.htm文件已经在本机了,包括a.files这样的一个文件夹,现在把这个改成a.mht文件,不会做,给点建议提示。。。
ahjoe 2008-03-14
  • 打赏
  • 举报
回复
用Internet Explorer打开 a.htm
然后,另存为 a.mht
calebgch 2008-03-12
  • 打赏
  • 举报
回复
C#我不会。。。
给我简单讲讲吧,行行好。
abupie 2008-03-11
  • 打赏
  • 举报
回复
private   void   ProduceMhtFile(string   URL,string   FileName)   
{
CDO.Message msg=new CDO.MessageClass();
msg.CreateMHTMLBody(URL,CDO.CdoMHTMLFlags.cdoSuppressAll,"","");
ADODB.Stream sw=msg.GetStream();
string urlPath = HttpContext.Current.Request.ApplicationPath + "/Temp/"; //虚拟目录
string physicPath = HttpContext.Current.Server.MapPath(urlPath); //物理地址
string strFileName=Guid.NewGuid()+".mht";
sw.SaveToFile(physicPath+strFileName,ADODB.SaveOptionsEnum.adSaveCreateOverWrite);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "mht";
HttpContext.Current.Response.WriteFile(urlPath+strFileName);
HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(FileName)+"");
HttpContext.Current.Response.Charset ="GB2312";
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.GetEncoding("GB2312");
HttpContext.Current.Response.ContentType ="text/mhtml";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
HttpContext.Current.Response.Flush();
System.IO.File.Delete(physicPath+strFileName);//删除临时文件
HttpContext.Current.Response.End();
}


一个朋友的代码,参考下吧.

64,849

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧