StringBuilder SBErrMag = new StringBuilder();
 SBErrMag.Append(" ");
 SBErrMag.Append(Environment.NewLine);//換行
string fileName = row.Cells[1].Text + "異常明細" + ".txt";
                    if (Request.Browser.Browser == "IE")
                    {
                        fileName = Server.UrlPathEncode(fileName);
                    }
                    string strContentDisposition = String.Format("{0}; filename=\"{1}\"", "attachment", fileName);
                    Response.AddHeader("Content-Disposition", strContentDisposition);
                    Response.Charset = "";
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    Response.ContentType = "application/vnd.text";
                    System.IO.StringWriter stringWrite = new System.IO.StringWriter();
                    System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
                    Response.Write(SBErrMag.ToString());
                    Response.End();
檢查指定路徑是否存在
不存在則新建
 if (!Directory.Exists("C:\\"))
                { Directory.CreateDirectory("C:\\"+"Name"); }
 
![[ASP.NET]驗證 判斷為非數字馬上清除填寫內容](https://4.bp.blogspot.com/-O3EpVMWcoKw/WxY6-6I4--I/AAAAAAAAB2s/KzC0FqUQtkMdw7VzT6oOR_8vbZO6EJc-ACK4BGAYYCw/w100/nth.png) 
0 留言