惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
IT之家
IT之家
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
U
Unit 42
爱范儿
爱范儿
博客园 - 聂微东
F
Fortinet All Blogs
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
L
LangChain Blog
雷峰网
雷峰网
B
Blog RSS Feed
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Engineering at Meta
Engineering at Meta
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - 庞滨

导出excel 查询优化 什么是iBATIS(一) 什么是iBATIS(二) 李彦宏在北大2008本科生毕业典礼上的发言 成长 何为sq注入 关闭网页框架父窗口,并跳转到一个新的窗口。 如何清除Session/设置Session超时, 如何显示当前的访问人数和总访问量. C#中数据库的连接 页面与页面之间如何传递值?如何获得 URL传过来的值. ASP.NET的错误处理机制 CSS样式 GridView的用法 使GidView变色 GridView中的双向排序 精美的HTML万年历 点击输入日期的TxtBox框后弹出js日期框供选择 C#正则表达式
C#如何生成一个XML文件,并保存在硬盘的指定目录下
庞滨 · 2008-06-13 · via 博客园 - 庞滨

1using System;
 2using System.Collections;
 3using System.ComponentModel;
 4using System.Data;
 5using System.Drawing;
 6using System.Web;
 7using System.Web.SessionState;
 8using System.Web.UI;
 9using System.Web.UI.WebControls;
10using System.Web.UI.HtmlControls;
11using System.IO;
12namespace UploadFile
13{
14    /// <summary>
15    /// Summary description for WebForm1.
16    /// </summary>

17    public partial class UploadPage : System.Web.UI.Page
18    {
19        private void Page_Load(object sender, System.EventArgs e)
20        {
21            try
22            {
23                string strXML = Request.QueryString["DefXML"];
24
25                string strFolder = "C:\\UploadFiles\\";
26                if (!System.IO.Directory.Exists(strFolder))
27                {
28                    System.IO.Directory.CreateDirectory(strFolder);
29                }

30                string strFileName = strFolder + DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss"+ ".xml";
31                FileStream fs = new System.IO.FileStream(strFileName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite);
32                StreamWriter sw = new System.IO.StreamWriter(fs);
33                sw.WriteLine(strXML);
34                sw.Flush();
35                sw.Close();
36                fs.Close();
37                Response.Write(strXML + "! File Save OK!");
38            }

39            catch (Exception ex)
40            {
41                Response.Write(ex.Message);
42            }

43            // Put user code to initialize the page here
44        }

45
46    //    #region Web Form Designer generated code
47        //override protected void OnInit(EventArgs e)
48    //    {
49    //        //
50    //        // CODEGEN: This call is required by the ASP.NET Web Form Designer.
51    //        //
52    //        InitializeComponent();
53    //        base.OnInit(e);
54    //    }
55
56    //    /// <summary>
57    //    /// Required method for Designer support - do not modify
58    //    /// the contents of this method with the code editor.
59    //    /// </summary>
60    //    private void InitializeComponent()
61    //    {
62    //        this.Load += new System.EventHandler(this.Page_Load);
63    //    }
64    //    #endregion
65    }

66}

67