如何将aspx文件另存为html文件和文件夹到本地计算机或服务器 [英] how to save aspx file as html file and folder to local machine or server

查看:162
本文介绍了如何将aspx文件另存为html文件和文件夹到本地计算机或服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Web应用程序中,我的客户希望将当前的aspx页面另存为html文件,并将相关文件(jquery,图像...)保存在一个文件夹中. 基本上,当您右键单击并在浏览器中按保存到"时,在后台执行的操作是我想通过单击按钮(webcontrol)来完成的.

in my web application my client wants to save the current aspx page as html file and also save the related file(jquery, images ...) in a folder. basically that what is being done in the background when you right click and press "save to" in the browser and I want to do that by a click of a button(webcontrol).

我发现一段代码可以保存html文件本身,但是我不知道如何保存相关文件夹.

i found a piece of code that will save the html file itself but i don't know how to save also the related folder.

private void SavePageASHtml(string location)
    {
        StringWriter stringWriter = new StringWriter();

        HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);

        Page.RenderControl(htmlWriter);

        htmlWriter.Flush();

        FileStream fileStream = new FileStream(location, FileMode.Create);

        string siteString = stringWriter.ToString();

        byte[] byteArray = Encoding.UTF8.GetBytes(siteString);

        fileStream.Write(byteArray, 0, byteArray.Length);

        fileStream.Close();

        Response.End();

        Response.Redirect("~/PriceList.aspx");
    }

推荐答案

这是一篇很老的文章,但是它显示了如何另存为MHT文件,这与我相信的要非常接近:

This is a pretty old article, but it shows how to save as an MHT file, which is quite close to what I believe you want:

http://www.eggheadcafe.com/articles/20040527.asp

这篇关于如何将aspx文件另存为html文件和文件夹到本地计算机或服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆