void AttachmentDownload_Click(object sender, EventArgs e) { Control _te = sender as Control; string _tagString = (_te.Tag == null) ? "" : _te.Tag.ToString(); string[] _strs = _tagString.Split(','); if (_strs.Length < 3) { XtraMessageBox.Show(string.Format("下载失败!错误的参数信息:{0}", _tagString), "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string _indexString = _strs[0]; SaveFileDialog _f = new SaveFileDialog(); using (MetaDataQueryServiceClient _msc = new MetaDataQueryServiceClient()) { _f.FileName = _msc.GetAttachFileName(_indexString, _strs[2]); if (_f.ShowDialog() == DialogResult.OK) { byte[] _fileBytes = _msc.GetAttachFileBytes(_indexString, _strs[1]); if (_fileBytes == null) { XtraMessageBox.Show("下载失败!取得的附件数据为空!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } FileStream stream = File.OpenWrite(_f.FileName); int _count = _fileBytes.Length; stream.Write(_fileBytes, 0, _count); stream.Close(); XtraMessageBox.Show("下载成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } }