0

This code works in development with IIS 7.5 for printing the extended attributes of a file, but does not find the attributes when running on the production server running IIS 8.

There are no errors and the attributes do appear in Windows Explorer.

Protected files as String = ""

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadDim videoPath As String = Server.MapPath("library/video/")
        Dim videoPath As String = Server.MapPath("library/video/")
        Dim videoFolder As New DirectoryInfo(videoPath)
        Dim attrib As String
        Dim titleDisplay As String

        For Each fil As FileInfo In videoFolder.GetFiles("*.mp4")
            titleDisplay = fil.Name().Replace(fil.Extension(), "")
        attrib = getAttribute(fil, "Title")
        If attrib.Length > 0 Then
            titleDisplay &= "<br /><b>" & attrib & "</b>"
        End If
        attrib = getAttribute(fil, "Tags")
        For Each att In attrib.Split(";")
            titleDisplay &= "<br /><i>" & att & "</i>"
        Next
        files &= "<p>" & titleDisplay & "</p>"
    Next
End Sub


Private Function getAttribute(ByVal file As FileInfo, ByVal attribute As String) As String

    Dim value As String = ""
    Dim shell As New Shell32.Shell()
    Dim fld As Shell32.Folder = shell.NameSpace(Path.GetDirectoryName(file.FullName))

    For Each s In fld.Items()
        If fld.GetDetailsOf(s, 0).ToLower() = Path.GetFileName(file.FullName).ToLowerInvariant Then
            For i As Integer = 0 To 34
                If fld.GetDetailsOf(fld.Items, i) = attribute Then
                    value = fld.GetDetailsOf(s, i)
                    Exit For
                End If
            Next
            Exit For
        End If
    Next

    Return value

End Function
  • What are the operating systems on each server? Also, what happens when it "doesn't work"? What have you tried to make it work? – Taegost May 04 '15 at 17:20
  • The development environment runs Windows 7, server is 2012. There is no error. It simply never finds the Title or Tags attributes even though they are on the file. – Matthew Tipton May 04 '15 at 20:33
  • I found this snippet that might help: "Check your server, may be you have to install the Media Foundation feature (windows server 2012: through Server Manager -> add Roles and features)" Source: http://www.codeproject.com/Questions/346199/Video-properties-not-getting-on-server-works-fine – Taegost May 04 '15 at 20:53
  • Thank you. Media Foundation does need to be installed. If it isn't, the attributes do not even appear in Windows Explorer. But it is, and they do. The shell32 still does not pick them up, however. – Matthew Tipton May 05 '15 at 02:26
  • To clarify: You're saying that the Media Foundation is installed on that server? – Taegost May 05 '15 at 12:57

0 Answers0