Want to know the subject/author/created date/etc... of a file in ASP.NET? Well you can use a slightly adapted version of my Classic ASP example. Note that the version below is for a server running on Windows 2000.
Function FileInfo(ByVal filename, ByVal Attribute)
Dim shortname
shortname = Right(filename, Len(filename) - InStrRev(filename, "\"))
Dim objShell = CreateObject("Shell.Application")
Dim objFolder = objShell.Namespace(Left(filename, InStrRev(filename, "\")))
Dim folderitem = objFolder.parsename(shortname)
Dim detail = ""
'// Windows 2000 attributes
'// =======================
'// Name, Size, Type, Modified, Attributes, Comments
'// Created, Accessed, Owner, Author, Title, Subject
'// Category, Pages, Copyright, CompanyName, ModuleDescription
'// ModuleVersion, ProductName, ProductVersion, SenderName
'// RecipientName, RecipientNumber, CSID, TSID, TransmissionTime
'// CallerID, Routing, AudioFormat, SampleRate, AudioSampleSize
'// AudioChannels, PlayLength, FrameCount, FrameRate
'// VideoSampleSize, VideoCompression
Select Case Attribute
Case "Size"
detail = objFolder.GetDetailsOf(folderitem, 1)
Case "Type"
detail = objFolder.GetDetailsOf(folderitem, 2)
Case "Modified"
detail = objFolder.GetDetailsOf(folderitem, 3)
Case "Attributes"
detail = objFolder.GetDetailsOf(folderitem, 4)
Case "Comments"
detail = objFolder.GetDetailsOf(folderitem, 5)
Case "Created"
detail = objFolder.GetDetailsOf(folderitem, 6)
Case "Accessed"
detail = objFolder.GetDetailsOf(folderitem, 7)
Case "Owner"
detail = objFolder.GetDetailsOf(folderitem, 8)
Case "Author"
detail = objFolder.GetDetailsOf(folderitem, 10)
Case "Title"
detail = objFolder.GetDetailsOf(folderitem, 11)
Case "Subject"
detail = objFolder.GetDetailsOf(folderitem, 12)
Case "Category"
detail = objFolder.GetDetailsOf(folderitem, 13)
Case "Pages"
detail = objFolder.GetDetailsOf(folderitem, 14)
Case "Copyright"
detail = objFolder.GetDetailsOf(folderitem, 15)
Case "CompanyName"
detail = objFolder.GetDetailsOf(folderitem, 16)
Case "ModuleDescription"
detail = objFolder.GetDetailsOf(folderitem, 17)
Case "ModuleVersion"
detail = objFolder.GetDetailsOf(folderitem, 18)
Case "ProductName"
detail = objFolder.GetDetailsOf(folderitem, 19)
Case "Version"
detail = objFolder.GetDetailsOf(folderitem, 20)
Case "SenderName"
detail = objFolder.GetDetailsOf(folderitem, 21)
Case "RecipientName"
detail = objFolder.GetDetailsOf(folderitem, 22)
Case "RecipientNumber"
detail = objFolder.GetDetailsOf(folderitem, 23)
Case "CSID"
detail = objFolder.GetDetailsOf(folderitem, 24)
Case "TSID"
detail = objFolder.GetDetailsOf(folderitem, 25)
Case "TransmissionTime"
detail = objFolder.GetDetailsOf(folderitem, 26)
Case "CallerID"
detail = objFolder.GetDetailsOf(folderitem, 27)
Case "Routing"
detail = objFolder.GetDetailsOf(folderitem, 28)
Case "AudioFormat"
detail = objFolder.GetDetailsOf(folderitem, 29)
Case "SampleRate"
detail = objFolder.GetDetailsOf(folderitem, 30)
Case "AudioSampleSize"
detail = objFolder.GetDetailsOf(folderitem, 31)
Case "AudioChannels"
detail = objFolder.GetDetailsOf(folderitem, 32)
Case "PlayLength"
detail = objFolder.GetDetailsOf(folderitem, 33)
Case "FrameCount"
detail = objFolder.GetDetailsOf(folderitem, 34)
Case "FrameRate"
detail = objFolder.GetDetailsOf(folderitem, 35)
Case "VideoSampleSize"
detail = objFolder.GetDetailsOf(folderitem, 36)
Case "VideoCompression"
detail = objFolder.GetDetailsOf(folderitem, 37)
End Select
Return (detail)
End Function
Use by calling:
FileInfo("C:\file.txt","Subject")