Exemple #1
0
 // 对选中文件进行共享
 private void button2_Click(object sender, EventArgs e)
 {
     if (this.textBox1.Text == null || this.textBox1.Text.Equals(""))
     {
         MessageBox.Show("请先选择文件");
     }
     else
     {
         IPAddress[]        ipa  = Dns.GetHostAddresses(Dns.GetHostName());
         string             ip   = ipa[ipa.Length - 1].ToString();
         System.IO.FileInfo file = new System.IO.FileInfo(this.textBox1.Text);
         long         len        = file.Length;
         NET.FileInfo fi         = new NET.FileInfo(this.textBox2.Text, ip, this.textBox1.Text);
         fi.Length       = len;
         fi.introduction = this.textBox6.Text;
         fi.keyList.Add(this.textBox2.Text);
         if (this.textBox3.Text != null && !this.textBox3.Text.Equals(""))
         {
             fi.keyList.Add(this.textBox3.Text);
         }
         if (this.textBox4.Text != null && !this.textBox4.Text.Equals(""))
         {
             fi.keyList.Add(this.textBox4.Text);
         }
         IP2P.Upload(fi);
         MessageBox.Show("共享成功!");
         this.button2.Enabled = false;
     }
 }