NetBlog主题
5465
public static string CutByteString(string str,int len){string result=string.Empty;// 最终返回的结果if(string.IsNullOrEmpty(str)) { return result; }int byteLen=System.Text.Encoding.Default.GetByteCount(str);// 单字节字符长度int charLen=str.Length;// 把字符平…
5474
static void Main(string[] args){string str = File.ReadAllText("1.txt", Encoding.Default);MatchCollection mc = Regex.Matches(str, @"([-a-zA-Z_0-9.]+)@([-a-zA-Z0-9_]+(\.[a-zA-Z]+)+)");foreach (Match m in mc){Console.WriteLine(m.Value);Con…
3604
public static void FileCopy(string source,string target){using (FileStream fileRead = new FileStream(source, FileMode.Open, FileAccess.Read)){byte[] bb = new byte[1024 * 1024 * 5];int r= fileRead.Read(bb, 0, bb.Length);using(FileStream fileWrite=new FileSt…
3383
/// <summary> /// 取得客户端真实IP。如果有代理则取第一个非内网地址 /// </summary> public static string GetIPAddress{get{var result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];if (!string.IsNullOrEmpty(resu…
4810
/// <summary> /// POST请求与获取结果 /// </summary> public string HttpPost(string Url, string postDataStr){HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);request.Method = "POST";request.ContentType = "applicat…
11069
2022-02-15 更新 以下是核心代码public static string ConnectionString = "Data Source= data.db;Pooling=true;FailIfMissing=false; ";public static int ExecuteSql(string SQLString, params SQLiteParameter[] p){//原创来自 http://www.luofenming.comusing (SQLiteC…
5280
2020-02-18 更新
实现一个delegate是很简单的,通过以下3个步骤即可实现一个delegate:
1. 声明一个delegate对象,它应当与你想要传递的方法具有相同的参数和返回值类型。
2. 创建delegate对象,并"将你想要传递的函数作为参数传入"。
3. 在要实现异步调用的地方,通过上一…
4135
20180530更新/// summary/// 写cookie值/// /summary/// param name="strName"名称/param/// param name="strValue"值/param/// param name="strValue"过期时间(分钟)/parampublic static void WriteCookie(string strName, string strValue, int expir…
2879
aspx页面<body><form id="form1" runat="server"><div>用户名:<input type="text" name="txtname" /><input type="submit" value="提交" /></div></form>
</body…
3063
/// <summary>/// 找到第一张图片/// </summary>/// <param name="htmlText"></param>/// <returns></returns>public static string GetFirstImages(string htmlText){const string pattern = "<img [^~]*?>"…