ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
**SaveAttachment** 保存附件,注:此方法只是保存附件,并不会保存附件字段内容,需再写代码保存附件字段内容,可将此方法返回的结果的文件名部分(不是文件完整路径)保存到附件字段里。如果有多个文件,用分号(;)连接再保存。 **返回值** List<string>,保存的文件名列表 **参数** | 名称 | 类型 | 描述 |必填 | --- | --- | --- |--- | | objContext| Entities| 数据库上下文 |是 | uid| int| 当前用户ID |是 | bizId| int| 业务数据ID |是 | entityId| int| 业务实体ID |是 | subFolder| string| 文件夹 |是 | attachments| string| 附件信息,格式:文件名1\*附件字段ID\\文件名2\*附件字段ID\\ |是 **示例** ```         private static void SaveFile(Entities objContext, int uid, int bizId, string base64)         {             var subFolder = Guid.NewGuid().ToString(); var entityId= 800000;//要改成对应的实体ID             var colId = 800000;//存储附件的字段(字符串类型)的列ID,查表 MD_EntityColumns获取,如果是公共附件,则传-1             var fileName = "xxx.pdf";//存成pdf的文件名 var folder=Path.Combine(DBAdminMan.RootPath, "upload", subFolder); Directory.CreateDirectory(folder);             var fullName = Path.Combine(folder, fileName);             File.WriteAllBytes(fullName, Convert.FromBase64String(base64));             AttachmentMan.SaveAttachment(objContext, uid, bizId, entityId, subFolder, $"{fileName}*{colId}\\"); objContext.ExecuteStoreCommand($"update t_biz set Files='xxx.pdf' where ID=@id", DBFactory.Factory.CreateParameter("id", bizId)); objContext.SaveChanges();         } ```