Exemplo n.º 1
0
 public void GetAvatar(string m_MaNV)
 {
     AvatarPath[0] = null;
     oFile.MaNV    = m_MaNV;
     oFile.Group.Clear();
     oFile.Group.Add(AvatarFileGroup);
     //oFile.FileType = CNVC_File.eFileType.Avatar;
     oFile.Link = null;
     dtAvatar   = oFile.GetData();
     if (dtAvatar != null && dtAvatar.Rows.Count > 0)
     {
         // Download
         string[] Paths = new string[1];
         Paths[0] = dtAvatar.Rows[0]["path"].ToString();
         if (Paths[0].ToString() != "")
         {
             try
             {
                 RemoveAvatar();
                 AvatarPath = oFTP.DownloadFile(Paths);
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Quá trình tải hình đại diện không thành công \r\n" + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     else
     {
         RemoveAvatar();
     }
 }
Exemplo n.º 2
0
        private void bw_download_DoWork(object sender, DoWorkEventArgs e)
        {
            //bw_download.ReportProgress(1);

            bool bSuccess = true;

            string[] SelectedPaths   = new string[dtgv_DSTapTin.SelectedRows.Count];
            string[] DownloadedPaths = new string[dtgv_DSTapTin.SelectedRows.Count];
            for (int i = 0; i < dtgv_DSTapTin.SelectedRows.Count; i++)
            {
                SelectedPaths[i] = dtgv_DSTapTin.SelectedRows[i].Cells["path"].Value.ToString();
            }

            try
            {
                DownloadedPaths = oFTP.DownloadFile(SelectedPaths);
                bSuccess        = true;
            }
            catch (Exception)
            {
                bSuccess = false;
                MessageBox.Show("Quá trình tải hình không thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            if (bSuccess)   // neu download thanh cong
            {
                for (int i = 0; i < DownloadedPaths.Count(); i++)
                {
                    string FileName = DownloadedPaths[i].ToString().Split('\\').Last();
                    // Use Path class to manipulate file and directory paths.
                    //string sourceFile = System.IO.Path.Combine(lsb_DSFile.SelectedItems[i].ToString(), FileName);
                    string destFile = System.IO.Path.Combine(FBD.SelectedPath, FileName);
                    try
                    {
                        File.Copy(DownloadedPaths[i].ToString(), destFile, true);
                    }
                    catch (Exception)
                    {
                        bSuccess = false;
                        MessageBox.Show("Quá trình tải hình không thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                if (bSuccess)
                {
                    MessageBox.Show("Quá trình tải hình thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }