Exemple #1
0
        /// <summary>
        /// 获取或设置是否需要创建表
        /// </summary>
        public void CreateTable()
        {
            String dataDir = DataCenter.GetUserPath() + "\\data";

            if (!CFileA.IsDirectoryExist(dataDir))
            {
                CFileA.CreateDirectory(dataDir);
            }
            String dataBasePath = dataDir + "\\" + DATABASENAME;

            m_connectStr = "Data Source = " + dataBasePath;
            if (!CFileA.IsFileExist(dataBasePath))
            {
                //创建数据库文件
                SQLiteConnection.CreateFile(dataBasePath);
                //创建表
                SQLiteConnection conn = new SQLiteConnection(m_connectStr);
                conn.Open();
                SQLiteCommand cmd = conn.CreateCommand();
                cmd.CommandText = CREATETABLESQL;
                cmd.ExecuteNonQuery();
                conn.Close();
                CreateDefaultProxyInfos();
            }
        }
Exemple #2
0
        /// <summary>
        /// 创建用户状态服务
        /// </summary>
        public UserCookieService()
        {
            String dataDir = DataCenter.GetUserPath() + "\\data";

            if (!CFileA.IsDirectoryExist(dataDir))
            {
                CFileA.CreateDirectory(dataDir);
            }
            String dataBasePath = DataCenter.GetUserPath() + "\\data\\usercookies.db";

            m_connectStr = "Data Source = " + dataBasePath;
            if (!CFileA.IsFileExist(dataBasePath))
            {
                CreateTable();
            }
        }
Exemple #3
0
        /// <summary>
        /// 获取用户目录
        /// </summary>
        /// <returns>用户目录</returns>
        public static String GetUserPath()
        {
            String userPath = Environment.GetEnvironmentVariable("LOCALAPPDATA");

            if (!CFileA.IsDirectoryExist(userPath))
            {
                userPath = GetAppPath();
            }
            else
            {
                userPath += "\\piratecat2";
                if (!CFileA.IsDirectoryExist(userPath))
                {
                    CFileA.CreateDirectory(userPath);
                }
            }
            return(userPath);
        }