public void AddFile(object file) { TAttachFile f = file as TAttachFile; DataRow row = _attachmentStorage.NewRow(); row[tb_AttachFile.DocID] = ""; row[tb_AttachFile.FileTitle] = f.FileTitle; row[tb_AttachFile.FileName] = f.FileName; row[tb_AttachFile.FileType] = f.FileType; row[tb_AttachFile.FileSize] = f.FileSize; row[tb_AttachFile.FileBody] = f.FileBody; row[tb_AttachFile.IsDroped] = f.IsDroped; row[tb_AttachFile.IconLarge] = f.IconLarge; row[tb_AttachFile.IconSmall] = f.IconSmall; _attachmentStorage.Rows.Add(row); }
public void AddFile(object file) { TAttachFile f = file as TAttachFile; DataRow row = _attachmentStorage.NewRow(); row[tb_sys_AttachFile.FID] = bllComDataBaseTool.GetTableID(tb_sys_AttachFile.__TableName, tb_sys_AttachFile.__KeyName); row[tb_sys_AttachFile.FDocID] = ""; row[tb_sys_AttachFile.FFileTitle] = f.FileTitle; row[tb_sys_AttachFile.FFileName] = f.FileName; row[tb_sys_AttachFile.FFileType] = f.FileType; row[tb_sys_AttachFile.FFileSize] = f.FileSize; row[tb_sys_AttachFile.FFileBody] = f.FileBody; row[tb_sys_AttachFile.FIsDroped] = f.IsDroped; row[tb_sys_AttachFile.IconLarge] = f.IconLarge; row[tb_sys_AttachFile.IconSmall] = f.IconSmall; _attachmentStorage.Rows.Add(row); }
public void UpdateFile(object file) { TAttachFile f = file as TAttachFile; DataRow[] rows = _attachmentStorage.Select("FileID=" + f.FileID.ToString());//查找旧记录 if (rows.Length > 0) { DataRow row = rows[0]; row[tb_AttachFile.DocID] = ""; row[tb_AttachFile.FileTitle] = f.FileTitle; row[tb_AttachFile.FileName] = f.FileName; row[tb_AttachFile.FileType] = f.FileType; row[tb_AttachFile.FileSize] = f.FileSize; row[tb_AttachFile.FileBody] = f.FileBody; row[tb_AttachFile.IsDroped] = f.IsDroped; row[tb_AttachFile.IconLarge] = f.IconLarge; row[tb_AttachFile.IconSmall] = f.IconSmall; } }
public void AddFile(string fileFullName) { FileStream fs = null; try { string ext = Path.GetExtension(fileFullName); //扩展名 string fileName = Path.GetFileName(fileFullName); //显示文件名称 fs = new FileStream(fileFullName, FileMode.Open); byte[] bs = new byte[fs.Length]; //文件内容 fs.Read(bs, 0, (int)fs.Length); //读取文件内容 decimal size = decimal.Round((decimal)(fs.Length / 1024.00), 2); //文件大小 kb fs.Close(); //显示文件的图标 Icon large; Icon small; AttachTool.CreateFileIcon(ext, out large, out small); //获取文件的图标 TAttachFile file = new TAttachFile(); //附件对象 file.FileName = fileName; file.FileTitle = fileName; //文件标题 file.FileType = ext; ////扩展名 file.FileSize = size; file.FileBody = bs; file.IconLarge = AttachTool.ImageToByte(large.ToBitmap()); //大图标 file.IconSmall = AttachTool.ImageToByte(small.ToBitmap()); //小图标 this.AddFile(file); //保存数据 } catch { if (fs != null) { fs.Close(); } } }