标签 C# 下的文章

1、合并file1.dll、file2.dll到destination.dll
ILmerge /ndebug /target:dll /out:C:\destination.dll /log C:\file1.dll C:\file2.dll
2、合并file1.dll、file2.dll以及myApp.exe到newApp.exe
ILmerge /ndebug /target:winexe /out:C:\
ewApp.exe /log C:\myapp.exe C:\file1.dll C:\file2.dll

注意:合并为exe时,myapp.exe必须写在file1.dll、file2.dll前面

自己写的哦~所以共享出来了~

using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.Globalization;
using System.IO;

namespace what

{
    class DES    {
        // 创建Key
        public string GenerateKey()
        {
            DESCryptoServiceProvider desCrypto = (DESCryptoServiceProvider)      

DESCryptoServiceProvider.Create();
            return ASCIIEncoding.ASCII.GetString(desCrypto.Key);
        }
        // 加密字符串
        public string EncryptString(string sInputString, string sKey)
        {
            byte[] data = Encoding.UTF8.GetBytes(sInputString);
            DESCryptoServiceProvider DES = new DESCryptoServiceProvider();
            DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
            DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
            ICryptoTransform desencrypt = DES.CreateEncryptor();
            byte[] result = desencrypt.TransformFinalBlock(data, 0, data.Length);
            return BitConverter.ToString(result);
        }
        // 解密字符串
        public string DecryptString(string sInputString, string sKey)
        {
            string[] sInput = sInputString.Split("-".ToCharArray());
            byte[] data = new byte[sInput.Length];
            for (int i = 0; i < sInput.Length; i++)
            {
                data[i] = byte.Parse(sInput[i], NumberStyles.HexNumber);
            }
            DESCryptoServiceProvider DES = new DESCryptoServiceProvider();
            DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
            DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
            ICryptoTransform desencrypt = DES.CreateDecryptor();
            byte[] result = desencrypt.TransformFinalBlock(data, 0, data.Length);
            return Encoding.UTF8.GetString(result);
        }

    }

}

 

C#的功能还是很强大的啊,哈哈~

由于要做一个地图学的作业,老师要求得写个分析程序,就草略的写了点~哈,效果还不错,就是饼图粗糙了点~下面就是截图:

02903d59ca9c22fb9d8204fe 1b1c7a6378a174f8e6113afe (1)

 

EXCEL导入DATASET的代码我就写在下面吧,可以帮助一下新手~

public void ExcelToDS(string Path)
        {

            string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Path + ";" + "Extended Properties=Excel 8.0;";
            OleDbConnection myConn = new OleDbConnection(strConn);
            myConn.Open();
            string strCom = "SELECT * FROM [Sheet1$]"; 
            OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, myConn);
            myDataSet = new DataSet();
            myCommand.Fill(myDataSet, "[Sheet1$]");
            myConn.Close();

            dataGridView1.DataMember = "[Sheet1$]";
            dataGridView1.DataSource = myDataSet;

        }

 

 

这里的Sheet1$就是那个Excel里的表一~名字不一样或者需要其他的表就改吧~

private void BindData()
        {
            GridView1.Visible = true;
            try
            {
                 conn.Open();
                if (conn.State == ConnectionState.Open)
                {
                    string cmd = "select * from charge";

                    SqlDataAdapter ad = new SqlDataAdapter(cmd, conn);

                    DataSet ds = new DataSet();
                    ad.Fill(ds);
                    GridView1.DataSource = ds;
                    GridView1.DataBind();
                    conn.Close();
                }
            }
            catch (System.Exception ea)
            {
             }
        }

protected void GridView1_PageIndexChanged(object sender, EventArgs e)
        {
            BindData();
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;

        }

        protected void GridView1_DataBound(object sender, EventArgs e)
        {
            GridViewRow bottomPagerRow = GridView1.BottomPagerRow;
            Label bottomLabel = new Label();
            bottomLabel.Text = "目前所在分页:(" + (GridView1.PageIndex + 1) + "/" + GridView1.PageCount + ")";
            bottomPagerRow.Cells[0].Controls.Add(bottomLabel);

        }

 

以上可以作为参考代码,本人今天研究了好久的咧~哈,大家试试吧,应该可以的~

睡觉去咯~不早了~

在Program.cs中添加如下代码:

Boolean createdNew; //返回是否赋予了使用线程的互斥体初始所属权
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Threading.Mutex instance = new System.Threading.Mutex(true, "MutexName", out createdNew); //同步基元变量
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (createdNew) //赋予了线程初始所属权,也就是首次使用互斥体
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Application.Run(new Form1()); /s/这句是系统自动写的
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; instance.ReleaseMutex();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MessageBox.Show("已经启动了一个程序,请先退出!","系统提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Application.Exit();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

 这就解决啦~很简单吧~哈哈