更新:2013-12-29
25
2013
01
24
2013
01
网站权限问题要重视-维护服务器后的看法
今天维护了一台某公司的网站服务器,就是访问文件突然不存在了,花了些时间看了一下,原因如下:
Global.asax 被改,变成了系统文件,还隐藏了。。
发布:pukuimin | 分类:c#/.net | 评论:0 | 浏览:
18
2013
01
SQLiteHelper类,操作SQLite数据库
操作类:
using System; using System.Data; using System.Text.RegularExpressions; using System.Xml; using System.IO; using System.Collections; using System.Data.SQLite; using System.Configuration;//添加.net引用 namespace Tools.Common { /// <summary> /// 对SQLite操作的类 /// 引用:System.Data.SQLite.dll【版本:3.6.23.1(原始文件名:SQlite3.DLL)】 /// </summary> public class SQLiteHelper { /// <summary> /// 所有成员函数都是静态的,构造函数定义为私有 /// </summary> private SQLiteHelper() { } /// <summary> /// 连接字符串 /// </summary> public static string ConnectionString {//"Data Source=Test.db3;Pooling=true;FailIfMissing=false"; get { ////(AppSettings节点下的"SQLiteConnectionString") string text = ConfigurationManager.AppSettings["SQLiteConnectionString"]; string str2 = ConfigurationManager.AppSettings["IsEncrypt"]; if (str2 == "true") { text = DesEncrypt.Decrypt(text); } return text; } } private static SQLiteConnection _Conn = null;
发布:pukuimin | 分类:c#/.net | 评论:0 | 浏览:
17
2013
01
c#利用反射,实现将model类变成字符串、再还原成mode对象的功能
处理类:
public string ToString(UserGiftCardModel model) { if (model == null) return ""; string sb = ""; Type type =model.GetType() ;//assembly.GetType("Reflect_test.PurchaseOrderHeadManageModel", true, true); //命名空间名称 + 类名 //创建类的实例 //object obj = Activator.CreateInstance(type, true); //获取公共属性 PropertyInfo[] Propertys = type.GetProperties();
发布:pukuimin | 分类:c#/.net | 评论:0 | 浏览:
15
2013
01
C#批量去掉文件前缀,最近用动软代码生成器,文件名在代码里改不了。
code:
static void Main(string[] args) { Console.WriteLine("本程序去掉当前目录及子目录下的文件前缀"); Console.Write("请输入要去掉的前缀:"); string stringFront = Console.ReadLine(); if (stringFront != "") { string dir = AppDomain.CurrentDomain.BaseDirectory; RenameFile(dir, stringFront); } else Console.WriteLine("请输入要去掉的前缀!"); Console.WriteLine("操作已完成"); Console.ReadKey(); } public static void RenameFile(string ParentDir,string stringFront) { string[] files = Directory.GetFiles(ParentDir, "*.cs", SearchOption.TopDirectoryOnly); foreach (string file in files) { string filename = Path.GetFileName(file); string pathname = Path.GetDirectoryName(file); if (filename.StartsWith(stringFront, true, null)) { filename = filename.Substring(stringFront.Length); FileInfo fi = new FileInfo(file); fi.MoveTo(Path.Combine(pathname,filename)); } } string[] dirs = Directory.GetDirectories(ParentDir); foreach(string dir in dirs) { RenameFile(dir,stringFront); } }
发布:pukuimin | 分类:c#/.net | 评论:0 | 浏览:
27
2012
10
c#程序片段,替换所有同名文件
code:
class Program { static void Main(string[] args) { try { replacefile rf = new replacefile(); rf.doReplace(@"F:\c1"); rf.doReplace(@"F:\c2"); rf.doReplace(@"F:\c3"); Console.WriteLine("替换完成!"); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } public class replacefile { public string sourceFilejs = @"F:\frmleftdown.js";//源文件 public string sourceFilexml = @"F:\frmleftdown.xml";//源文件 public void doReplace(string parentPath) { string[] files = Directory.GetFiles(parentPath); foreach (string f in files) { if (f=="frmleftdown.js") File.Copy(sourceFilejs, f, true);//替换目录下所有的同名文件 if (f=="frmleftdown.xml") File.Copy(sourceFilexml, f, true); } string[] subdirs = Directory.GetDirectories(parentPath); foreach (string subdir in subdirs) { doReplace(subdir); } } }
发布:pukuimin | 分类:c#/.net | 评论:0 | 浏览:
25
2012
10
vs2010中使用Nunit测试c#代码结果的正确性
发布:pukuimin | 分类:c#/.net | 评论:0 | 浏览:
25
2012
10
02
2012
09
01
2012
09
[转载]验证正则表达式集合-1
常用表达式:
asp.net 验证正则表达式 整数或者小数:^[0-9]+\.{0,1}[0-9]{0,2}$ 只能输入数字:"^[0-9]*$"。 只能输入n位的数字:"^\d{n}$"。 只能输入至少n位的数字:"^\d{n,}$"。 只能输入m~n位的数字:。"^\d{m,n}$" 只能输入零和非零开头的数字:"^(0|[1-9][0-9]*)$"。 只能输入有两位小数的正实数:"^[0-9]+(.[0-9]{2})?$"。 只能输入有1~3位小数的正实数:"^[0-9]+(.[0-9]{1,3})?$"。 只能输入非零的正整数:"^\+?[1-9][0-9]*$"。 只能输入非零的负整数:"^\-[1-9][]0-9"*$。
发布:pukuimin | 分类:c#/.net | 评论:0 | 浏览: