真爱无限的知识驿站

学习积累技术经验,提升自身能力

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;


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();


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@qq.com联系

留言时,请留下称呼或姓名

<< < 1 2 >>

Powered By Z-BlogPHP 1.7.3

Copyright 2024-2027 pukuimin Rights Reserved.
粤ICP备17100155号