浙林龙哥

   :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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

posted on 2004-12-31 11:56  浙林龙哥  阅读(544)  评论(0编辑  收藏  举报