zoukankan      html  css  js  c++  java
  • 保存为客户端文件

       A a = new A();
       a.m = 10;
       string urlPath = HttpContext.Current.Request.ApplicationPath;
       string _file = HttpContext.Current.Server.MapPath(String.Format("{0}/{1}.xml",urlPath,Guid.NewGuid()));
       
       XmlSerializer ser = new XmlSerializer(typeof(A));
       TextWriter wr = new StreamWriter(_file, false,Encoding.UTF8);
       ser.Serialize(wr,a);
       wr.Close();

       HttpResponse response = HttpContext.Current.Response;
       response.Clear();
       response.WriteFile(_file);
       string httpHeader="attachment;filename=drawout.xml";
       response.AppendHeader("Content-Disposition", httpHeader);
       response.End();

  • 相关阅读:
    目录
    mysql 常用命令复习
    mysql备份及pymysql
    mysql 表操作
    mysql 库操作
    mysql 数据库
    各种推导式
    python 之I/O模型
    python 之进程
    python之 多线程(二)
  • 原文地址:https://www.cnblogs.com/huqingyu/p/84707.html
Copyright © 2011-2022 走看看