Example #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;
     }
 }
Example #2
0
 // 对选中的文件进行下载操作
 private void button4_Click(object sender, EventArgs e)
 {
     if (this.listView1.SelectedItems != null)
     {
         string         path;
         string         filename = this.listView1.SelectedItems[0].SubItems[0].Text;
         string         ip       = this.listView1.SelectedItems[0].SubItems[1].Text;
         string         mp       = this.listView1.SelectedItems[0].SubItems[2].Text;
         SaveFileDialog sfd      = new SaveFileDialog();
         sfd.CheckFileExists = false;
         sfd.FileName        = filename;
         if (sfd.ShowDialog() == DialogResult.OK)
         {
             path = System.IO.Path.GetFileName(sfd.FileName);
             NET.FileInfo fi = new NET.FileInfo(filename, ip, mp);
             IP2P.Download(fi, path);
         }
     }
 }
Example #3
0
 // 对选中的文件进行下载操作
 private void button4_Click(object sender, EventArgs e)
 {
     if (this.listView1.SelectedItems != null)
     {
         string path;
         string filename = this.listView1.SelectedItems[0].SubItems[0].Text;
         string ip = this.listView1.SelectedItems[0].SubItems[1].Text;
         string mp = this.listView1.SelectedItems[0].SubItems[2].Text;
         SaveFileDialog sfd = new SaveFileDialog();
         sfd.CheckFileExists = false;
         sfd.FileName = filename;
         if (sfd.ShowDialog() == DialogResult.OK)
         {
             path = System.IO.Path.GetFileName(sfd.FileName);
             NET.FileInfo fi = new NET.FileInfo(filename, ip, mp);
             IP2P.Download(fi, path);
         }
     }
 }
Example #4
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;
     }
 }