日期:2014-05-17 浏览次数:21077 次
private void saveAs(DataRow data)
{
int attachid = data["AttachID"].ToInt();
string fileName = data["FileName"].ToString();
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "*|*.*";
sfd.FileName = fileName;
sfd.FilterIndex = 0;
//sfd.RestoreDirectory = true;
if (sfd.ShowDialog() == DialogResult.OK)
{
if (sfd.OpenFile() != null)
{
string sql = string.Format("select FileContent from FormAttachment where AttachID = {0}", attachid);
byte[] content = (byte[])DataBridge.WSS.ExecuteScalar(sql);
if (!File.Exists(sfd.FileName))
{
File.Create(sfd.FileName).Close();
}
//System.IO.File.WriteAllBytes(sfd.FileName, content); //报错:正由另一进程使用,因此该进程无法访问此文件。
MemoryStream ms = new MemoryStream(content);