Example #1
0
 private void downloadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //  string a =selected.Item.Text;
     if (selected.Item != null)
     {
         byte[] buff = hostInstance.Download(path + selected.Item.Text);
         saveFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
         saveFileDialog1.Filter           =
             "All files (*.*)|*.*|All files (*.*)|*.*";
         saveFileDialog1.FileName = selected.Item.Text;
         if (saveFileDialog1.ShowDialog() == DialogResult.OK && saveFileDialog1.FileName != string.Empty)
         {
             try
             {
                 FileStream   fs = new FileStream(saveFileDialog1.FileName, FileMode.Create, FileAccess.ReadWrite);
                 BinaryWriter bw = new BinaryWriter(fs);
                 bw.Write(buff);
                 bw.Close();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             MessageBox.Show("Tải về hoàn thành!! ");
         }
     }
     else
     {
         MessageBox.Show("Bạn chưa chọn tập tin");
     }
 }