c# http上传/sqlite数据库助手/分割字符/Cskin窗体设置/线程间无效操作

1.http 上传

/// <summary>
        /// http 请求
        /// </summary>
        /// <param name="Url"></param>
        /// <param name="postDataStr"></param>
        /// <returns></returns>
        private string HttpPostNew(string Url, string postDataStr)
        {
            //string post_string = Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(postDataStr));
            byte[] postBytes = Encoding.GetEncoding("utf-8").GetBytes(postDataStr);
            HttpWebRequest request = WebRequest.Create(Url) as HttpWebRequest;//(HttpWebRequest)WebRequest.Create(Url);
            request.Method = "POST";
            //request.ContentType = "application/x-www-form-urlencoded";
            request.ContentType = "application/json";

            request.ContentLength = postBytes.Length;//Encoding.UTF8.GetByteCount(post_string);
                                                     // request.CookieContainer = cookie;

            Stream myRequestStream = request.GetRequestStream();
            //StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.GetEncoding("utf-8"));           
            //myStreamWriter.Write(post_string);
            //myStreamWriter.Close();


            myRequestStream.Write(postBytes, 0, postBytes.Length);
            myRequestStream.Close();

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            //response.Cookies = cookie.GetCookies(response.ResponseUri);
            Stream myResponseStream = response.GetResponseStream();
            StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
            string retString = myStreamReader.ReadToEnd();
            myStreamReader.Close();
            myResponseStream.Close();

            return retString;
        }

2.sqlite 数据库助手

public class SQLiteHelper
    {
        SQLiteConnection m_dbConnection;
        public SQLiteHelper()
        {
            //路径为同项目的sqlite文件夹下的db文件
            string connectionstr = string.Format(@"Data Source=" + System.Environment.CurrentDirectory.ToString() + "//PWRSModelDB.db");
            m_dbConnection = new SQLiteConnection(connectionstr);
            if (m_dbConnection.State == ConnectionState.Closed)
                m_dbConnection.Open();
        }
        //查
        public DataTable SelectALL(string sql)
        {
            DataTable ds = new DataTable();
            try
            {
                SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
                SQLiteDataAdapter sdp = new SQLiteDataAdapter(command);
                sdp.Fill(ds);
                sdp.Dispose();
                return ds;
            }
            catch (Exception e)
            {
                return ds;
            }

        }
        //增/删/改
        public bool insert_update_delete_Data(string sql)
        {
            try
            {
                SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
                command = new SQLiteCommand(sql, m_dbConnection);
                command.ExecuteNonQuery();
                return true;
            }
            catch
            {
                return false;
            }
        }
}

3.分割字符

string[] arrTemp = "abc,abcd,abcdef,abcdefg,abcdefgh".Split(',');

4.Cskin窗体设定

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(63)))), ((int)(((byte)(65)))));
            this.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(63)))), ((int)(((byte)(65)))));
            this.CaptionBackColorBottom = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(63)))), ((int)(((byte)(65)))));
            this.CaptionBackColorTop = System.Drawing.Color.FromArgb(((int)(((byte)(49)))), ((int)(((byte)(51)))), ((int)(((byte)(53)))));
            this.CaptionFont = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.ClientSize = new System.Drawing.Size(1920, 1200);
            this.InnerBorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(63)))), ((int)(((byte)(65)))));
            this.Name = "MianForm";
            this.Text = " Sokan";
            this.TitleCenter = true;
            this.TitleColor = System.Drawing.Color.White;
            this.ResumeLayout(false);

5.线程间无效操作

CheckForIllegalCrossThreadCalls = false;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值