?
Solved

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

Posted on 2008-11-19
5
Medium Priority
?
1,075 Views
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 codeproject.com (http://www.codeproject.com/KB/cs/ntfsstreams.aspx) 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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<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;}
    </style>  
</head>
<body>
<%
    Dim directory As String = "\\server-02\documents\intranet\safety & labels"
    Dim dirInfo As New DirectoryInfo(directory)
 
    articleList.DataSource = dirInfo.GetFiles("*.*")
    articleList.BorderWidth = 0
    articleList.DataBind()
%>
    
    <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">
 
      <Columns>
        <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}" />  
      </Columns>
 
    </asp:DataGrid>  
 
    
</body>
</html>

Open in new window

0
Comment
Question by:mark1per
  • 4
5 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 23004013
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.
0
 

Author Comment

by:mark1per
ID: 23004790
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.

file-summary-screenshot.gif
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 23005737
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.

Reference:
The Dsofile.dll files lets you edit Office document properties when you do not have Office installed
http://support.microsoft.com/?id=224351


// Source:
// The Dsofile.dll files lets you edit Office document properties when you do not have Office installed
// http://support.microsoft.com/?id=224351
 
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()
    {
        _DocumentProperties.Close(false);
 
        Marshal.ReleaseComObject(_DocumentProperties);
    }
 
    #endregion
}
 
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

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 23005743
Example usage:

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

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 23005777
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.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

862 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