C # Saves a piece of HTML code as an. html file

Source: Internet
Author: User

1#regionSave File
2 PublicvoidSaveFile (StringBuilder strhtml)
3{
4stringTpxxid = request.querystring["Fbwzid"];
5Try
6{
7Model.tp_tpxx mtpxx = Ctpxx.getmodel (TPXXID);
8stringf = System.Configuration.ConfigurationManager.AppSettings
9
Ten["Savefilepath"] +"files\\"+
One
Asystem.configuration.configurationmanager.appsettings["Syscode"]; Addresses configured in the Web configuration file
-//Save Address
-stringFilePath = f +"\ \ website publishing \ \"+string. Format ("{0:YYYY-MM-DD}",
the
-DateTime.Now) +"\\"+ Tpxxid +"\\"+ MTPXX.TPBT +". html";
-
-
+if(! Directory.Exists (Path.getdirectoryname (FilePath)))
-{
+ //Create Path
ADirectory.CreateDirectory (Path.getdirectoryname (FilePath));
at}
-
-//Create HTML file, write HTML, full path with extension
-File.delete (FilePath);
-File.appendalltext (FilePath, strhtml.tostring (), encoding.default);
-
inClientscript.registerclientscriptblock (GetType (),"Script","<script
-
toType='Text/javascript'Defer>alert ('Publish successfully! '); newcommon.windowclose
+
-();</script>");
the
*}
$Catch(Exception ex)
Panax Notoginseng{
-
theThrow;
+}
A}
the#endregion

C # Saves a piece of HTML code as an. html file

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.