Listing files and file summary information (title, subject, author) from a folder on a remote server (same domain)

Posted on 2008-11-19
Last Modified: 2013-11-08
I am running MS Visual Web Dev 2008 Express and I have found some code that lists files in a remote directory (see below).  This list is for a list of PDF files.  The listing works except for the links, but I will leave that for another question.  

I want the file list to show "title", "subject", "author" as well (this information can be viewed / changed if you right click on a file in windows explorer and choose the Summary tab).

I found code on ( that is supposed to allow this listing (I could not attach the zip file, so you will have to download it).  

How can I use this code in my file listing to show file summary information?
<%@ Page Language="vb" AutoEventWireup="false" %>

<%@ Import Namespace="System.IO" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">


<html xmlns="" >

<head runat="server">

    <title>File Listing with Summary Info</title>


    <style type="text/css">  

    body,td,th { font-family:tahoma;font-size:8pt }

    a {text-decoration:none;}





    Dim directory As String = "\\server-02\documents\intranet\safety & labels"

    Dim dirInfo As New DirectoryInfo(directory)


    articleList.DataSource = dirInfo.GetFiles("*.*")

    articleList.BorderWidth = 0




    <asp:DataGrid runat="server" id="articleList" Font-Names="Verdana" Width="100%"

        AutoGenerateColumns="False" AlternatingItemStyle-BackColor="#eeeeee"

        HeaderStyle-BackColor="Gray" HeaderStyle-ForeColor="White" AllowSorting="true"

        HeaderStyle-Font-Size="10pt" HeaderStyle-Font-Bold="True" Font-Size="10pt" CellPadding="4" BorderWidth="0">



        <asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name" HeaderText="File Name" />

        <asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Write Time" ItemStyle-HorizontalAlign="Center" DataFormatString="{0:d}" />        

        <%--<asp:BoundColumn DataField="CreationTime" HeaderText="Created" DataFormatString="{1:d}" />--%>

        <asp:BoundColumn DataField="Length" HeaderText="File Size" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:#,### bytes}" />  








Open in new window

Question by:mark1per
    LVL 96

    Expert Comment

    by:Bob Learned
    I set a DataGrid (in 3.5 a GridView would be better), that has columns defined, and it is bound to the directory.  I am confused what you are really looking for.

    Author Comment

    Hello TheLearnedOne: I don't mean to sound trivial, but I will explain the data I am referring to for you and for anyone else trying to understand what I mean ...

    Open an Explorer Window, right click on a *.pdf file, in the Dialog box click on Properties, then click the Summary tab.  In the Summary tab you will see fields listed: Title, Subject, Author, etc.  Then add data to those fields (if not already populated) and click OK.  Then, in the original Explorer Window, right click on the column heading and click More... (at the bottom).  Check Title, Subject, Author then click OK.  You then should see the information that you entered in the columns.  See attached screen shot.

    It is this information that I wish to extract and display in my ASP page / DataGridView.

    LVL 96

    Accepted Solution

    I don't know if this will help you, but I have this managed wrapper class that I worked on a while ago, that borrowed from the DSOFile COM library to get document summary information.

    The Dsofile.dll files lets you edit Office document properties when you do not have Office installed

    // Source:
    // The Dsofile.dll files lets you edit Office document properties when you do not have Office installed
    using DSOFile;
    using System;
    using System.Runtime.InteropServices;
    public class DocumentSummaryReader : IDisposable
        private OleDocumentProperties _DocumentProperties = null;
        public DocumentSummaryReader(string fileName)
            // Open the OLE document file from the disk.
            _DocumentProperties = new OleDocumentProperties();
            _DocumentProperties.Open(fileName, true, dsoFileOpenOptions.dsoOptionDefault);
        public SummaryPropertyInfo GetDocumentSummary()
            SummaryPropertyInfo info = new SummaryPropertyInfo();
            info.ApplicationName = _DocumentProperties.SummaryProperties.ApplicationName;
            info.Version = _DocumentProperties.SummaryProperties.Version;
            info.Subject = _DocumentProperties.SummaryProperties.Subject;
            info.Category = _DocumentProperties.SummaryProperties.Category;
            info.Company = _DocumentProperties.SummaryProperties.Company;
            info.Keywords = _DocumentProperties.SummaryProperties.Keywords;
            info.Manager = _DocumentProperties.SummaryProperties.Manager;
            info.LastSavedBy = _DocumentProperties.SummaryProperties.LastSavedBy;
            info.WordCount = _DocumentProperties.SummaryProperties.WordCount;
            info.PageCount = _DocumentProperties.SummaryProperties.PageCount;
            info.ParagraphCount = _DocumentProperties.SummaryProperties.ParagraphCount;
            info.LineCount = _DocumentProperties.SummaryProperties.LineCount;
            info.CharacterCount = _DocumentProperties.SummaryProperties.CharacterCount;
            info.CharacterCountWithSpaces = _DocumentProperties.SummaryProperties.CharacterCountWithSpaces;
            info.ByteCount = _DocumentProperties.SummaryProperties.ByteCount;
            info.PresentationFormat = _DocumentProperties.SummaryProperties.PresentationFormat;
            info.SlideCount = _DocumentProperties.SummaryProperties.SlideCount;
            info.NoteCount = _DocumentProperties.SummaryProperties.NoteCount;
            info.HiddenSlideCount = _DocumentProperties.SummaryProperties.HiddenSlideCount;
            info.MultimediaClipCount = _DocumentProperties.SummaryProperties.MultimediaClipCount;
            info.DateCreated = this.ParseDate(_DocumentProperties.SummaryProperties.DateCreated);
            info.DateLastPrinted = this.ParseDate(_DocumentProperties.SummaryProperties.DateLastPrinted);
            info.DateLastSaved = this.ParseDate(_DocumentProperties.SummaryProperties.DateLastSaved);
            info.TotalEditTime = _DocumentProperties.SummaryProperties.TotalEditTime;
            info.Template = _DocumentProperties.SummaryProperties.Template;
            info.RevisionNumber = _DocumentProperties.SummaryProperties.RevisionNumber;
            info.IsSharedDocument = _DocumentProperties.SummaryProperties.SharedDocument;
            if (_DocumentProperties.IsOleFile)
                info.ClsId = new Guid(_DocumentProperties.CLSID.ToString());
                info.ProgId = _DocumentProperties.ProgID;
                info.OleDocumentFormat = _DocumentProperties.OleDocumentFormat;
                info.OleDocumentType = _DocumentProperties.OleDocumentType;
            return info;
        private DateTime ParseDate(object value)
            DateTime result;
            if (value != null)
                if (DateTime.TryParse(value.ToString(), out result))
                    return result;
            return DateTime.MinValue;
        #region IDisposable Members
        public void Dispose()
    public class SummaryPropertyInfo
        public string ApplicationName;
        public string Version;
        public string Subject;
        public string Category;
        public string Company;
        public string Keywords;
        public string Manager;
        public string LastSavedBy;
        public int WordCount;
        public int PageCount;
        public int ParagraphCount;
        public int LineCount;
        public int CharacterCount;
        public int CharacterCountWithSpaces;
        public int ByteCount;
        public string PresentationFormat;
        public int SlideCount;
        public int NoteCount;
        public int HiddenSlideCount;
        public int MultimediaClipCount;
        public DateTime DateCreated;
        public DateTime DateLastPrinted;
        public DateTime DateLastSaved;
        public int TotalEditTime;
        public string Template;
        public string RevisionNumber;
        public bool IsSharedDocument;
        public Guid ClsId;
        public string ProgId;
        public string OleDocumentFormat;
        public string OleDocumentType;

    Open in new window

    LVL 96

    Expert Comment

    by:Bob Learned
    Example usage:

                using (DocumentSummaryReader reader = new DocumentSummaryReader(@"c:\my documents\compliance table.doc"))
                    SummaryPropertyInfo properties = reader.GetDocumentSummary();

    LVL 96

    Expert Comment

    by:Bob Learned
    The DSOFile library lets you read and write properties, but I just went down the road of a read-only class, so there is a way, if you want to have a DocumentSummaryWriter class.  I just didn't need anything like that at the time.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now