Sunday, February 22, 2009

Document library internal fields

Recently i was needed to use OpenXml in Moss (hopefully i will write on this soon), one of the issue i needed to handle was the fact that it will only work of office 2007 files and not on pdf/office 2003/txt files and more.

After  a short google seach i found all the relevant suffix (http://msdn.microsoft.com/en-us/library/aa338205.aspx , http://office.microsoft.com/en-us/word/HA100069351033.aspx), so all i needed is the file suffix. However, i was very surprised to find out that non of the SPFile properties or the SPListItem properties contains the document suffix (the last one make sense).

Then i remembered that sharepoint document library (as so list) have hidden/frombase/readonly fields that contains all kind of parameters, like:

BaseName - Document prefix.
FileLeafRef - Prefix.Suffix.
EncodedAbsUrl - Full document url.
DocIcon - Document suffix.
Author - Created by.
Editor - Modified by.
FileDirRef - Directory id and directory name (seperated by  ;#).
ContentTypeId - Content type id.
FileSizeDisplay - File size.
GUID - File guid.

So i used the DocIcon field to get the suffix and to check if the document support OpenXml.

No comments:

Post a Comment