private void btnDownload_Click(object sender, EventArgs e) { try { DataGridViewSelectedRowCollection selectedRows = this.gvData.SelectedRows; if (selectedRows.Count == 0) { MessageBox.Show("请选择!"); return; } else if (selectedRows.Count > 1) { MessageBox.Show("只能选择一行!"); return; } String type = Util.Util.ConvertObjToString(selectedRows[0].Cells[objTypeStr].Value); if (type.Equals(this.directoryType)) { MessageBox.Show("选择的是文件夹!"); return; } String bosUri = Util.Util.ConvertObjToString(selectedRows[0].Cells[this.keyStr].Value); String fileName = Util.Util.ConvertObjToString(selectedRows[0].Cells[this.objNameStr].Value); String selectedBucketName = lbSelectedBucket.Text.Replace("选中的Bucket:", ""); BosUtil bosUtil = new BosUtil(); String uriPath = bosUtil.getFileUrl(selectedBucketName, bosUri); DownloadUtil downloadUtil = new DownloadUtil(); SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = fileName; DialogResult result = sfd.ShowDialog(); String path = sfd.FileName; if (result.Equals(DialogResult.OK)) { downloadUtil.DownloadFile(uriPath, path, pbProcess); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }