开发者

Save the file type icon in DATABASE or in a XML file or

I am using c#,wpf and mvvm.

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.

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.

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...

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

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.

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" />
<开发者_Go百科/FileTypes>

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...

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


Always avoid keeping binary images in databases. query and covertion are over heads. the best way for this particular option is to keep all ur pics as resourcess and keep the resource name saved to the database .. u can do tht by keep a enum of the resource names and parse the (eNUM.PARSE) names at onrowdatabound as source binding to cell template of a datagrid row. the cell may contain an image as template content.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜