dll 中的二进制数据难以管理
目前,我们在 C# 解决方案中将报告模板(word 文档)作为二进制数组存储在 dll 中。
public readonly static byte[] audit_engagement_template = new byte[] {208,207,17,224,161,177,26,225,0,0,0,0,0,0,0,0,...
等等。现在这个文件已经变得巨大并且非常难以管理,因为 Visual Studio 只要打开它就开始使用超过 2.5Gb 的内存。
我们曾经将此数据存储在数据库中,但是我们需要使数据库占用空间尽可能小,并减少从客户端打开/编辑这些模板时使用的带宽。这就是我们将这些文件直接移至解决方案中的原因。
任何人都可以建议任何存储这些文件的替代方案(并且不允许客户从应用程序外部接触它们)吗?
Currently we store report templates (word docs) as binary arrays within a dll in our C# solution.
public readonly static byte[] audit_engagement_template = new byte[] {208,207,17,224,161,177,26,225,0,0,0,0,0,0,0,0,...
Etc etc. Now this file has become HUGE and very unmanageable as Visual Studio starts using over 2.5Gb of memory whenever it is open.
We used to store this data in a database, however we need to make our database footprint as small as possible as well as reduce the bandwidth used when opening/editing these templates from the client's side. This is why we moved these files directly into the solution.
Can anyone suggest any alternatives on going about storing these files (and not allowing the clients to touch them from outside of the application)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要将它们放入二进制数组中,而是尝试将文件作为嵌入资源包含在 DLL 中,然后使用
Assembly.GetManifestResourceStream
加载它们。检查一下,但我认为这可能会更有效......并且它肯定会更好地分离代码和数据。Rather than putting them in binary arrays, try including the files as embedded resources in the DLL, then using
Assembly.GetManifestResourceStream
to load them. Check, but I think that may be more efficient... and it will certainly be a better separation of code and data.你使用什么数据库? SQL Server 将使用
FILESTREAM
功能执行您想要的操作。它使用本地文件系统来存储文件,因此它们仅存在于文件夹中,但可以通过 SQL 访问它们。备份变得更加容易,并且可以轻松授予只读访问权限。有关详细信息,请参阅MSDN 文章。
What database are you using? SQL Server will do what you want using the
FILESTREAM
feature. It uses the local filesystem to store the files, so they simply exist in a folder, but they are accessed via SQL. Backing up becomes much easier, and it's easy to grant read-only access.See the MSDN article for more information.