C#有没有实现IE的 Save As功能的办法? 现在想实现下面的功能:当我浏览一个网页的时候,自动保存当前页为一个.htm文件。就像手工点击了File => Save As保存页面一样。请问C#能够实现吗?Thank you!!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在你程序中打开网页的时候,自己写一个save函数不就行了 使用javascript,通过document对象另存为 yuxiang9999(用C#重载比尔盖茨)具体怎么做,能讲的更详细一点吗?C#中怎么调用javascript sendkey 直接调用MS的 save as using System;namespace Libin.Web{ /// <summary> /// 实现IE中文件另存为功能类。 /// </summary> public class Download { /// <summary> /// 构建器 /// </summary> /// <param name="fileFullPath">文件全路径名</param> public Download(string fileFullPath) { this.setFileFullName(fileFullPath); this.splitFileName(); this.doDownload(); } /// <summary> /// 构建器 /// </summary> /// <param name="path">文件路径</param> /// <param name="fileName">文件名</param> public Download(string path,string fileName):this(path+fileName) { } /// <summary> /// 执行下载方式(另存为) /// </summary> private void doDownload() { byte[] byteFileData=new IO.File(this.getFileFullName()).getBytes(); if(byteFileData==null) { this.isSuccessful=false; } else { System.Web.HttpContext.Current.Response.ClearHeaders(); fileName = System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(this.getFileFullName())); System.Web.HttpContext.Current.Response.ContentType="application/zip;"; System.Web.HttpContext.Current.Response.Charset="UTF-8"; System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename=\"{0}\"",this.getFileName())); System.Web.HttpContext.Current.Response.BinaryWrite(byteFileData); System.Web.HttpContext.Current.Response.End(); this.isSuccessful=true; } } private string fileName; /// <summary> /// 设置文件名称 /// </summary> /// <param name="fileName">文件名称</param> public void setFileName(string fileName) { this.fileName=fileName; } /// <summary> /// 获取文件名称 /// </summary> /// <returns>文件名称</returns> public string getFileName() { return this.fileName; } private string path; private void setPath(string path) { this.path=path; } private string fileFullName; /// <summary> /// 设置文件全路径名 /// </summary> /// <param name="fileFullName">文件全路径名</param> public void setFileFullName(string fileFullName) { this.fileFullName=fileFullName; } /// <summary> /// 获取文件全路径名 /// </summary> /// <returns>文件全路径名</returns> public string getFileFullName() { return this.fileFullName; } private bool isSuccessful; /// <summary> /// 获取运行成功标志 /// </summary> /// <returns>true:成功</returns> public bool getIsSucessfule() { return this.isSuccessful; } /// <summary> /// 分离文件简名 /// </summary> private void splitFileName() { this.fileName=this.fileFullName.Substring(this.fileFullName.LastIndexOf("\\")+1); } }}//使用方法:// new Libin.Web.Download("C:\test.txt"); 我现在的问题是没有URL,因为是ASP.NET网页,只能用SendKey,好像不太好 如何学C# clickonce如何发布带有数据库的c#编写的客户端应用程序?新年骑鹿拜谢!! ===========求教高手=========== windows 7 C# 添加账户 用C#递归求第19位数 为感谢 greystar 大哥帮助,在此把全部分给他 没分了,,低分求一个问题,,hyperlink 让控件动起来 c#中的事件等待处理方法 UML问题 从流中获取数据构成图片时(Imange.fromSteam(stream s))发生GDI+一般性错误,请高手解决 一条语句错误,帮忙修正下
{
/// <summary>
/// 实现IE中文件另存为功能类。
/// </summary>
public class Download
{
/// <summary>
/// 构建器
/// </summary>
/// <param name="fileFullPath">文件全路径名</param>
public Download(string fileFullPath)
{
this.setFileFullName(fileFullPath);
this.splitFileName();
this.doDownload();
}
/// <summary>
/// 构建器
/// </summary>
/// <param name="path">文件路径</param>
/// <param name="fileName">文件名</param>
public Download(string path,string fileName):this(path+fileName)
{
} /// <summary>
/// 执行下载方式(另存为)
/// </summary>
private void doDownload()
{
byte[] byteFileData=new IO.File(this.getFileFullName()).getBytes();
if(byteFileData==null)
{
this.isSuccessful=false;
}
else
{
System.Web.HttpContext.Current.Response.ClearHeaders();
fileName = System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(this.getFileFullName())); System.Web.HttpContext.Current.Response.ContentType="application/zip;";
System.Web.HttpContext.Current.Response.Charset="UTF-8";
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename=\"{0}\"",this.getFileName())); System.Web.HttpContext.Current.Response.BinaryWrite(byteFileData);
System.Web.HttpContext.Current.Response.End(); this.isSuccessful=true;
}
} private string fileName;
/// <summary>
/// 设置文件名称
/// </summary>
/// <param name="fileName">文件名称</param>
public void setFileName(string fileName)
{
this.fileName=fileName;
}
/// <summary>
/// 获取文件名称
/// </summary>
/// <returns>文件名称</returns>
public string getFileName()
{
return this.fileName;
} private string path; private void setPath(string path)
{
this.path=path;
} private string fileFullName;
/// <summary>
/// 设置文件全路径名
/// </summary>
/// <param name="fileFullName">文件全路径名</param>
public void setFileFullName(string fileFullName)
{
this.fileFullName=fileFullName;
}
/// <summary>
/// 获取文件全路径名
/// </summary>
/// <returns>文件全路径名</returns>
public string getFileFullName()
{
return this.fileFullName;
} private bool isSuccessful;
/// <summary>
/// 获取运行成功标志
/// </summary>
/// <returns>true:成功</returns>
public bool getIsSucessfule()
{
return this.isSuccessful;
} /// <summary>
/// 分离文件简名
/// </summary>
private void splitFileName()
{
this.fileName=this.fileFullName.Substring(this.fileFullName.LastIndexOf("\\")+1);
}
}
}
//使用方法:
// new Libin.Web.Download("C:\test.txt");