c#抽簽系統(tǒng)的實(shí)現(xiàn)示例
一個(gè)基于c#的簡單抽簽系統(tǒng),可以重新導(dǎo)入數(shù)據(jù),清空數(shù)據(jù)。
代碼簡單,比較適合初學(xué)者。
導(dǎo)入數(shù)據(jù)時(shí)會(huì)創(chuàng)建一個(gè)txt文本,可以在里面看到輸入
private void button1_Click(object sender, EventArgs e) //確定按鈕 { string path = System.IO.Directory.GetCurrentDirectory() + "http://name.txt"; Random rand = new Random(System.Guid.NewGuid().GetHashCode()); string[] name = File.ReadAllLines(path); if (name.Length == 0) { MessageBox.Show("導(dǎo)入數(shù)據(jù)不能為空!"); } else { textBox1.Text = name[rand.Next(0, name.Length)]; //抽簽 textBox1.ForeColor = Color.Black; } } private void button3_Click(object sender, EventArgs e) //導(dǎo)入數(shù)據(jù) { string qkong = ""; //清空name.TXT string CurDir11 = System.AppDomain.CurrentDomain.BaseDirectory + @"name.txt.txt"; String filePath11 = CurDir11; System.IO.StreamWriter file11 = new System.IO.StreamWriter(filePath11, false); / file11.Write(qkong); file11.Close(); file11.Dispose(); string result = textBox2.Text.Trim(); string d = System.AppDomain.CurrentDomain.BaseDirectory + @"name.txt"; String filePath = d; System.IO.StreamWriter file1 = new System.IO.StreamWriter(filePath, false); file1.Write(result); file1.Close(); file1.Dispose(); MessageBox.Show("導(dǎo)入成功"); } private void button4_Click(object sender, EventArgs e) //清空數(shù)據(jù) { string qkong = ""; string s = System.AppDomain.CurrentDomain.BaseDirectory + @"name.txt.txt"; String filePath11 = s; System.IO.StreamWriter file11 = new System.IO.StreamWriter(filePath11, false); file11.Write(qkong); file11.Close(); file11.Dispose(); textBox2.Text = ""; } private void textBox2_TextChanged(object sender, EventArgs e) { this.textBox2.Multiline = true; }
到此這篇關(guān)于c#抽簽系統(tǒng)的實(shí)現(xiàn)示例的文章就介紹到這了,更多相關(guān)c# 抽簽系統(tǒng)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
基于C#實(shí)現(xiàn)12306的動(dòng)態(tài)驗(yàn)證碼變成靜態(tài)驗(yàn)證碼的方法
這篇文章主要介紹了基于C#實(shí)現(xiàn)12306的動(dòng)態(tài)驗(yàn)證碼變成靜態(tài)驗(yàn)證碼的方法的相關(guān)資料,需要的朋友可以參考下2015-12-12c#打印預(yù)覽控件中實(shí)現(xiàn)用鼠標(biāo)移動(dòng)頁面功能代碼分享
項(xiàng)目中需要實(shí)現(xiàn)以下功能:打印預(yù)覽控件中,可以用鼠標(biāo)拖動(dòng)頁面,以查看超出顯示范圍之外的部分內(nèi)容,下面就是實(shí)現(xiàn)代碼2013-12-12使用HttpHanlder處理404:File not found的問題
本篇文章小編為大家介紹。使用HttpHanlder處理404:File not found的問題。需要的朋友參考下2013-04-04C#導(dǎo)出pdf的實(shí)現(xiàn)方法(瀏覽器不預(yù)覽直接下載)
這篇文章主要給大家介紹了關(guān)于C#導(dǎo)出pdf的實(shí)現(xiàn)方法,實(shí)現(xiàn)后瀏覽器不預(yù)覽就可以直接下載,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用C#具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-12-12