现在想实现下面的功能:
当我浏览一个网页的时候,自动保存当前页为一个.htm文件。
就像手工点击了File => Save As保存页面一样。请问C#能够实现吗
?Thank you!!!!

解决方案 »

  1.   

    在你程序中打开网页的时候,自己写一个save函数不就行了
      

  2.   

    使用javascript,通过document对象另存为
      

  3.   

    yuxiang9999(用C#重载比尔盖茨)具体怎么做,能讲的更详细一点吗?C#中怎么调用javascript
      

  4.   

    sendkey  直接调用MS的 save as
      

  5.   

    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");
      

  6.   

    我现在的问题是没有URL,因为是ASP.NET网页,只能用SendKey,好像不太好