public static void DownLoadFile(ListView lv,List<OA_Annex> list)
{
byte[] bytes = null;
foreach (ListViewItem item in lv.SelectedItems)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Title = "另存为";
foreach (OA_Annex obj in list)
{
if (obj.AnnexName.Equals(item.Text))
{
sfd.FileName = item.Text;
bytes = obj.Dataannex;
}
}
sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
DialogResult dr = sfd.ShowDialog();
if (dr == DialogResult.OK)
{
FileStream fs;
FileInfo fi = new System.IO.FileInfo(sfd.FileName);
fs = fi.OpenWrite();
fs.Write(bytes, 0, bytes.Length);
fs.Close();
MessageBox.Show("导出成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}