.net常用的方法
???????//用javascript判斷是否去那個頁面
??????Response.Write("<script language=\"javascript\" type=\"text/javascript\">");
??????Response.Write("if(confirm('是否去那個頁面。')){ document.URL='LookContent.aspx'}");
??????Response.Write("</script>");
??????//傳遞信息時如果有中文最好用以下函數轉換一下HttpUtility.UrlEncode()
??????http://www.abc.com/SameArticle.aspx?type=classify&title=" + HttpUtility.UrlEncode("標題")
??????//獲取某頁面傳遞過來的問號信息
??????Request.QueryString["title"]
??????//獲取服務器路徑
??????System.Web.HttpRuntime.AppDomainAppPath?
??????//日期胡亂轉換
??????string dtString = "19831015121015";
??????IFormatProvider culture = new System.Globalization.CultureInfo("zh-CN", true);
??????DateTime dt = DateTime.ParseExact(dtString, "yyyyMMddHHmmss", culture, DateTimeStyles.NoCurrentDateDefault); //大寫HH是24小時制,小寫hh是12小時制
??????Console.WriteLine(dt.ToString());
??????//DataTable 排序方法
????????DataView dvBriefing = dtBriefing.DefaultView;
??????? dvBriefing.Sort = "CommentCount DESC";
??????? dtBriefing = dvBriefing.ToTable();
??????//Asp.net 快速寫txt文件
??????StreamWriter swOutTime = new StreamWriter("c:\\TempOutTime.txt", true, System.Text.Encoding.GetEncoding("GB2312"));
??????swOutTime.Write("寫入txt文件");
??????swOutTime.Flush();
??????swOutTime.Close();
??????//Asp.net DataTable寫XML
??????1、寫用dtBriefing.WriteXml("C:\\temp.xml", XmlWriteMode.WriteSchema);
??????2、讀用DataSet dllxml = new DataSet();
????????????????????dllxml.ReadXml("C:\\temp.xml");
????????????????????dtBriefing = dllxml.Tables[0];?
??????????
??????? // 判斷是否合法的IP地址
??????? static private bool isIpAdd(string url)
??????? {
??????????? url = CleanURL(url);
??????????? System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"(\d{1,3}\.){3}\d{1,3}");
??????????? if (url == reg.Match(url).ToString())
??????????? {
??????????????? if (reg.Match(url).Success)
??????????????? {
??????????????????? string[] ips = url.Split('.');
??????????????????? if (ips.Length == 4 || ips.Length == 6)
??????????????????? {
??????????????????????? if (System.Int32.Parse(ips[0]) < 256 && System.Int32.Parse(ips[1]) < 256 & System.Int32.Parse(ips[2]) < 256 & System.Int32.Parse(ips[3]) < 256)
??????????????????????????? return true;
??????????????????????? else
??????????????????????????? return false;
??????????????????? }
??????????????? }
??????????? }
??????????? return false;
??????? }
??????Response.Write("<script language=\"javascript\" type=\"text/javascript\">");
??????Response.Write("if(confirm('是否去那個頁面。')){ document.URL='LookContent.aspx'}");
??????Response.Write("</script>");
??????//傳遞信息時如果有中文最好用以下函數轉換一下HttpUtility.UrlEncode()
??????http://www.abc.com/SameArticle.aspx?type=classify&title=" + HttpUtility.UrlEncode("標題")
??????//獲取某頁面傳遞過來的問號信息
??????Request.QueryString["title"]
??????//獲取服務器路徑
??????System.Web.HttpRuntime.AppDomainAppPath?
??????//日期胡亂轉換
??????string dtString = "19831015121015";
??????IFormatProvider culture = new System.Globalization.CultureInfo("zh-CN", true);
??????DateTime dt = DateTime.ParseExact(dtString, "yyyyMMddHHmmss", culture, DateTimeStyles.NoCurrentDateDefault); //大寫HH是24小時制,小寫hh是12小時制
??????Console.WriteLine(dt.ToString());
??????//DataTable 排序方法
????????DataView dvBriefing = dtBriefing.DefaultView;
??????? dvBriefing.Sort = "CommentCount DESC";
??????? dtBriefing = dvBriefing.ToTable();
??????//Asp.net 快速寫txt文件
??????StreamWriter swOutTime = new StreamWriter("c:\\TempOutTime.txt", true, System.Text.Encoding.GetEncoding("GB2312"));
??????swOutTime.Write("寫入txt文件");
??????swOutTime.Flush();
??????swOutTime.Close();
??????//Asp.net DataTable寫XML
??????1、寫用dtBriefing.WriteXml("C:\\temp.xml", XmlWriteMode.WriteSchema);
??????2、讀用DataSet dllxml = new DataSet();
????????????????????dllxml.ReadXml("C:\\temp.xml");
????????????????????dtBriefing = dllxml.Tables[0];?
??????????
??????? // 判斷是否合法的IP地址
??????? static private bool isIpAdd(string url)
??????? {
??????????? url = CleanURL(url);
??????????? System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"(\d{1,3}\.){3}\d{1,3}");
??????????? if (url == reg.Match(url).ToString())
??????????? {
??????????????? if (reg.Match(url).Success)
??????????????? {
??????????????????? string[] ips = url.Split('.');
??????????????????? if (ips.Length == 4 || ips.Length == 6)
??????????????????? {
??????????????????????? if (System.Int32.Parse(ips[0]) < 256 && System.Int32.Parse(ips[1]) < 256 & System.Int32.Parse(ips[2]) < 256 & System.Int32.Parse(ips[3]) < 256)
??????????????????????????? return true;
??????????????????????? else
??????????????????????????? return false;
??????????????????? }
??????????????? }
??????????? }
??????????? return false;
??????? }
轉載于:https://www.cnblogs.com/ghostljj/archive/2007/01/25/630230.html
總結
- 上一篇: QQ,MSN,SKYPE等在线状态代码
- 下一篇: AE 模板 天使之城