保存文件类型图标在数据库或XML文件或 [英] Save the file type icon in DATABASE or in a XML file or

查看:157
本文介绍了保存文件类型图标在数据库或XML文件或的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#,WPF和MVVM。

I am using c#,wpf and mvvm.

在我的DataGrid的每一行都有在最后一个单元格与涉及此行,我称之为一个时期的文件的列表框

In my datagrid every row has in the last cell a ListBox with documents related to this row which I call a period.

用户可以将文档添加到每个时期。

The user can add documents to every period.

我要显示给每个文档文件类型图标(16×16)和document`s名称。

I want to display for every document the file type icon(16x16) and the document`s name.

文件类型图标让我有点头疼的。

The file type icon gives me a bit of a headache.

我不知道我阉应该节约每文档数据库中,因为每天的文件类型图标像.DOC也许有10个周期的每个贴有这样我在数据库中保存20图标这是19倍多余的...

I am not sure wether I should save every documents file type icon like .DOC in the database because a day has maybe 10 periods each has 2 .DOC files attached thus I save 20 icons in the database which are 19 times redundant...

大多数东西我的用户将附加的办公室文件类型,如.xls的,.DOC,.PDF,图像,ZIP / RAR完蛋了,我猜。

Most stuff my user will attach are Office file types like .xls,.doc,.pdf,images,zip/rar thats it I guess.

另一个但在技术上更先进的是保存独特的文件类型在与该文件类型的扩展以键/值对的XML文件图标作为编码的基本-64字符串。

Another but technically more advanced would be to save the unique file type icon as encoded base-64 string in a XML file with the file type extension as key/value pair.

XML被加载一次在应用程序中的字典一次启动

The xml is loaded one time in a dictionary one time at application start up

<FileTypes>
<Extension ext="doc" base64string="ff5598sdfusd98fjs9df98sd9f" />
<Extension ext="docx" base64string="ff5498sdfusd98fjs9df98sd9f" />
<Extension ext="xls" base64string="ff9548sdfdsfdfusd98fjs9df98sd9f" />
<Extension ext="xlsx" base64string="ff98sfdfddfusd98fjs9df98sd9f" />
<Extension ext="pdf" base64string="ff98fdfdsdfusd98fjs9df98sd9f" />
<Extension ext="zip" base64string="ff98dfdfsdfusd98fjs9df98sd9f" />
<Extension ext="rar" base64string="fffdf98sdfusd98fjs9df98sd9f" />
</FileTypes>



每当一个文件下来我检查文件名的文件扩展名和检索字典数据库以获得该文件的BASE64字符串。我仍然可以以某种方式实现对文件类型的base64字符串缓存机制,所以我不每次我得到一个.doc文件时对它们进行解码...

Every time a document comes down the database I check the file extension in the file name and retrieve the dictionary to get the base64 string for the file. I could still somehow implement a caching mechanism for the file type base64 string so I do not decode them every time I get a .doc file...

也许你有一个相当不同的/更好?的想法,请让我知道,或为数据库/ XML节能优势/ disadvantes建议:)

Maybe you have a quite different/better ? idea, please let me know or make suggestions about advantages/disadvantes of database/xml saving :)

推荐答案

如果你有几个文件类型和文件,其更好的一个巨大的数字,你存储的文件类型为file_type_master一种数据库或XML文件,并在你到处使用一次加载它。但是,当出现在装载和使用方面是一个很好的权衡它拥有不错的。否则,你也可以做类型的缓存。

If you have few file types and a huge number of files, its better that you store the file types as a file_type_master kind of database or XML file and load it once while you use it everywhere. But it holds good when there is a good trade off in terms of loading and usage. Or else you can also do kind of caching.

这篇关于保存文件类型图标在数据库或XML文件或的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆