随笔分类 -  C#

摘要:public void SetLog(string content) { string hh = Server.MapPath("/log/") + DateTime.Now.ToString("yyyyMMdd") + ".txt"; ... 阅读全文
posted @ 2014-07-24 09:53 lampon 阅读(1024) 评论(0) 推荐(0)
摘要:1 概述正则表达式(Regular Expression)是一种匹配模式,描述的是一串文本的特征。正如自然语言中“高大”、“坚固”等词语抽象出来描述事物特征一样,正则表达式就是字符的高度抽象,用来描述字符串的特征。正则表达式(以下简称正则,Regex)通常不独立存在,各种编程语言和工具作为宿主语言提... 阅读全文
posted @ 2014-07-04 09:25 lampon 阅读(190) 评论(0) 推荐(0)
摘要://从控件上传文件 public void fileUpload() { System.Web.HttpFileCollection files = Request.Files; for (int fileCount = 0; fileCount < files.Count; fileCount++) { System.Web.HttpPostedFile postedfile = files[fileCount]; string... 阅读全文
posted @ 2014-04-08 16:25 lampon 阅读(190) 评论(0) 推荐(0)
摘要:/// /// 读取Excel文档 /// /// 文件名称 /// 返回一个数据集 public DataSet ExcelToDS(string Path) { string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +"Data Source="+ Path +";"+"Extended Properties=Excel 8.0;"; OleDbConnection conn = new OleDbConnection(strConn); conn.Open( 阅读全文
posted @ 2014-04-08 11:43 lampon 阅读(223) 评论(0) 推荐(0)
摘要:C#中执行SQL语句//SQL查询语句 public DataTable query(string sql) { //server=127.0.0.1; DataTable dt=new DataTable(); //DataRow dr; string connString = "server=127.0.0.1;uid=sa;pwd=;database=TJPTTC"; SqlConnection conn = new SqlConnection(connString); SqlDataAdapter adapter = new SqlDataAdapter(s... 阅读全文
posted @ 2014-03-18 14:58 lampon 阅读(7010) 评论(0) 推荐(0)
摘要:WebClient private string GetWebClient(string url) { string strHTML = ""; WebClient myWebClient = new WebClient(); Stream myStream = myWebClient.OpenRead(url); StreamReader sr = new StreamReader(myStream, System.Text.Encoding.GetEncoding(this.txtEncoder.Text)); strHTML = sr.ReadToEnd(); ... 阅读全文
posted @ 2014-02-13 11:34 lampon 阅读(335) 评论(0) 推荐(0)
摘要:public string Tohtml(string zifu) { string noStyle = zifu.Replace("&quot;", "\"").Replace("&lt;", "").Replace("&quot;", "\"").Replace("", ""); noStyle = Regex.Replace(noStyle, @"", "& 阅读全文
posted @ 2014-02-08 16:46 lampon 阅读(2434) 评论(0) 推荐(0)
摘要:DataSet添加新列DataSet ds = jhPhotoAlbum.GetList("JH5='" + key + "'");ds.Tables[0].Columns.Add("count", typeof(System.String));for (int i = 0; i 10) { DataTable dt = new DataTable(); dt = ds.Tables[0].Clone(); for (int i = 0; i < 10; i++) ... 阅读全文
posted @ 2013-12-11 14:41 lampon 阅读(1176) 评论(0) 推荐(0)
摘要:#region 保存web图片到本地 /// /// 保存web图片到本地 /// /// web图片路径 /// 保存路径 /// 保存文件名 /// public static string SaveImageFromWeb(string imgUrl, string path, string fileName) { if (path.Equals("")) throw new Exception("未指定保存文件的路径"); string imgName = imgUrl.ToS... 阅读全文
posted @ 2013-11-12 14:59 lampon 阅读(9317) 评论(1) 推荐(0)
摘要:如果file框没有加runat="server",则form里一定要加上 enctype="multipart/form-data"这样才可以实现上传文件到服务器;使用了server和没有使用 runat="server"是有区别的.使用了runat="server"的form编译后,action必定是指向本身的网页。而没 有加runat="server"的form可以指向一个网页。 服务端代码: private string retvalue = "ok"; protect 阅读全文
posted @ 2013-11-12 14:54 lampon 阅读(953) 评论(0) 推荐(0)
摘要:using System;using System.Collections.Generic;using System.Text;using System.IO;using System.Drawing;using System.Drawing.Drawing2D;using System.Drawing.Imaging;namespace WuJian.Common{ /// /// 图片处理 /// http://www.cnblogs.com/wu-jian/ /// /// 吴剑 2011-02-20 创建 /// 吴剑 2012-08-08 修改... 阅读全文
posted @ 2013-11-12 14:49 lampon 阅读(265) 评论(0) 推荐(0)
摘要:方法一: //须添加对System.Web的引用 using System.Web.Security; ... /// /// SHA1加密字符串 /// /// 源字符串 /// 加密后的字符串 public string SHA1(string source) { return FormsAuthentication.HashPasswordForStoringInConfigFile(source, "SHA1"); } /// /// MD5加密字符串 /// /// 源字符... 阅读全文
posted @ 2013-10-23 20:31 lampon 阅读(233) 评论(0) 推荐(0)
摘要:1.雅虎天气预报网站:http://hk.weather.yahoo.com/(1)主要的软件有雅虎天气软件,传统黄历91黄历天气v2.0.1等(2) 提供的天气预报接口的说明:如下使用雅虎访问程序的解析参考如下网址http://download.csdn.net/download/zsd406095755/3676406http://bbs.9ria.com/thread-49642-1-1.htmlhttp://kb.cnblogs.com/page/42993/2/yahoo天气预报的url是http://weather.yahooapis.com/forecastrss?w=21513 阅读全文
posted @ 2013-06-27 13:40 lampon 阅读(1868) 评论(0) 推荐(1)
摘要:System.Diagnostics.Process p = new Process(); p.StartInfo.UseShellExecute = true; p.StartInfo.FileName = @"D:\text.txt"; p.Start(); 阅读全文
posted @ 2013-06-27 13:12 lampon 阅读(1020) 评论(0) 推荐(0)
摘要:url 请求的路径地址 postData 传入的参数 public static string Post(string url, string postData) { CookieContainer cookieContainer = new CookieContainer(); Uri URI = new Uri(url); byte[] byteArr = Encoding.UTF8.GetBytes(postData); HttpWebRequest request = WebReq... 阅读全文
posted @ 2013-06-27 11:58 lampon 阅读(306) 评论(0) 推荐(0)
摘要:第1种://通过传入的特定XML字符串,通过 ReadXml函数读取到DataSet中。 protected static DataSet GetDataSetByXml(string xmlData) { try { DataSet ds = new DataSet(); using (StringReader xmlSR = new StringReader(xmlData)) { ds.ReadXml(... 阅读全文
posted @ 2013-06-27 11:55 lampon 阅读(287) 评论(0) 推荐(0)
摘要:是webservice.就概念上来说,可能比较复杂,不过我们可以有个宏观的了解:webservice就是个对外的接口,里面有函数可供 外部客户调用(注意:里面同样有客户不可调用的函数)。假若我们是服务端,我们写好了个webservice,然后把它给了客户(同时我们给了他们调用规 则),客户就可以在从服务端获取信息时处于一个相对透明的状态。即使客户不了解(也不需要)其过程,他们只获取数据。 webservice传递的数据只能是序列化的数据,典型的就是xml数据。下面以一个简单例子为例:(一)新建——-项目---Visual C#---web---ASP.NET Web 服务应用程序,命名为Te. 阅读全文
posted @ 2013-06-23 20:18 lampon 阅读(220) 评论(0) 推荐(0)
摘要:注记 :Pascal 大小写形式-所有单词第一个字母大写,其他字母小写。Camel 大小写形式-除了第一个单词,所有单词第一个字母大写,其他字母小写。正文:1. 类名使用Pascal 大小写形式public class HelloWorld{ ...}2. 方法使用Pascal 大小写形式public class HelloWorld{ void SayHello(string name) { ... }}3. 变量、方法参数、数据成员使用Camel 大小写形式public class HelloWorld{ int totalCount = 0; void SayHello(stringna 阅读全文
posted @ 2013-06-23 20:01 lampon 阅读(232) 评论(0) 推荐(0)