For years I've used the file properties in Word to store information about the files I generate (see Figure 1). When I was first looking for an easy way to put Word documents on an intranet, my thoughts turned to this file properties dialog. If there were a way to read the file properties, I could just pull in this information when I wanted to create a list of files, then write an ASP page to read this information, format it, and provide links to the documents. This was easier said than done, however. I started searching for the easiest way to access this information, and quickly struck paydirt on MSDNâ¢. To begin with, I learned about OLE Structured Storage and how it works. According to Microsoft, access to COM Structured Storage is through a set of APIs, and for more information you should check out the Platform SDK or search MSDN on Structured Storage. The problem with these APIs is that they're not Automation-compatible, and they can't be accessed directly from Visual BasicÂ® or scripting code. Fortunately, I also found DSOFILE, an in-process ActiveX DLL that allows you to read the file properties for any OLE Structured Storage file. DSOFILE was written specifically to give programmers using Visual Basic access to this data. Once I had downloaded a copy of DSOFILE (http://support.microsoft.com/support/kb/articles/Q224/3/51.ASP), I was almost ready. The last thing I needed was a way to walk the directory of files. For that I turned to the FSO, a simple interface to the file system that's available with IIS and Internet Explorer 4.0 or higher. First, you should download and run the DSOFILE component. This is a self-extracting ZIP file that contains a copy of DSOFILE.DLL as well as some sample code. Second, place a copy of the DLL in your WindowsÂ® System32 subdirectory, then run
<%@ Language=VBScript %>
dim objFSO ' File System Object
dim objFile ' File Object
dim objFolder ' Folder Object
set objFSO = createobject("Scripting.FileSystemObject")
dim objPropReader ' Property Reading object
dim objFileProps ' Object that stores the file properties
Set objPropReader = CreateObject("DSOLEFILE.PropertyReader")
dim sMapPath ' String to store the Real Path
if trim(objFileProps.Title) = "" then
if objFile.size < 10240 then
Response.Write objFile.size & " Bytes"
elseif objFile.size < 1048576 then
Response.Write round(objFile.size/1024,1) & "KB"
Response.Write round((objFile.size/1024)/1024,1) & "MB"
<TD width="*"> <%=objFileProps.Comments%> </TD>
Josef Finsel is a consultant with Rapidigm, specializing in developing intranet and Internet solutions that use Microsoft products. He can be reached at http://www.finsel.com.
From the March 2000 issue of MSDN Magazine.
More MSDN Magazine Blog entries >
Browse All MSDN Magazines
Subscribe to MSDN Flash newsletter
Receive the MSDN Flash e-mail newsletter every other week, with news and information personalized to your interests and areas of focus.