어떻게 VB.net을 사용하여 Windows 파일의 세부 정보를 얻을 수 있습니까?확장 된 파일 정보 세부 정보 얻기
파일의 오른쪽을 클릭하면 MS 워드 doc을 말한 다음 '속성'을 클릭하고 '세부 정보'탭을 선택하면 세부 정보 유형이 표시됩니다.
FileInfo를 통해 일부를 얻을 수 있지만 전부는 아닙니다 (예 : "태그"). 감사합니다.
어떻게 VB.net을 사용하여 Windows 파일의 세부 정보를 얻을 수 있습니까?확장 된 파일 정보 세부 정보 얻기
파일의 오른쪽을 클릭하면 MS 워드 doc을 말한 다음 '속성'을 클릭하고 '세부 정보'탭을 선택하면 세부 정보 유형이 표시됩니다.
FileInfo를 통해 일부를 얻을 수 있지만 전부는 아닙니다 (예 : "태그"). 감사합니다.
Shell32를 사용해야합니다. COM 탭에서 Microsoft 셸 컨트롤 및 자동화을 찾아 추가하십시오.
Dim xtd As List(Of ShellInfo) = GetXtdShellInfo("C:\Temp\Capri.jpg")
For Each s As ShellInfo In xtd
Console.WriteLine("{0}: {1}", s.Name, s.Value)
Next
: 그것은 간단합니다 사용하여 다음
' class to hold the goodies
Friend Class ShellInfo
Public Property Name As String
Public Property Value As String
Public Sub New(n As String, v As String)
Name = n
Value = v
End Sub
Public Overrides Function ToString() As String
Return Name
End Function
End Class
Private Function GetXtdShellInfo(filepath As String) As List(Of ShellInfo)
' ToDo: add error checking, maybe Try/Catch and
' surely check if the file exists before trying
Dim xtd As New List(Of ShellInfo)
Dim shell As New Shell32.Shell
Dim shFolder As Shell32.Folder
shFolder = shell.NameSpace(Path.GetDirectoryName(filepath))
' its com so iterate to find what we want -
' or modify to return a dictionary of lists for all the items
Dim key As String
For Each s In shFolder.Items
' look for the one we are after
If shfolder.GetDetailsOf(s, 0).ToLowerInvariant = Path.GetFileName(file).ToLowerInvariant Then
Dim ndx As Int32 = 0
key = shfolder.GetDetailsOf(shfolder.Items, ndx)
' there are a varying number of entries depending on the OS
' 34 min, W7=290, W8=309 with some blanks
' this should get up to 310 non blank elements
Do Until String.IsNullOrEmpty(key) AndAlso ndx > 310
If String.IsNullOrEmpty(key) = False Then
xtd.Add(New ShellInfo(key,
shfolder.GetDetailsOf(s, ndx)))
End If
ndx += 1
key = shfolder.GetDetailsOf(shfolder.Items, ndx)
Loop
' we got what we came for
Exit For
End If
Next
Return xtd
End Function
를 그것을 채우기 위해 기능 : 다음 코드는 주어진 파일의 속성 - 값 목록을 만드는 것입니다 return은 Name, BitRate, Album
과 같은 속성 이름이고 연결된 Value
은에 의해 반환되는 ShellInfo
항목의 목록이어야합니다. 10. 예를 들어
Name: Capri.jpg
Size: 15.2 KB
Item type: Image File
Date modified: 7/20/2014 12:19 PM
Date created: 7/20/2014 12:17 PM
Date accessed: 7/20/2014 12:17 PM
(etc)
주석에 마이크로 소프트 쉘 컨트롤을 지적하고 자동화이 마이크로 소프트 쉘 폴더보기 라우터로 이름이 변경되기 때문에
버전 OS에 따라 달라집니다 반환되는 실제 수 (의 Windows 8.1).
또한 첫 번째 35 개의 속성이 널리 알려져 있지만 Win7의 경우 약 291 개가 있습니다. Windows 8에서는 최대 빈칸이 309 개이고 목록의 일부 속성 색인이 변경됩니다.
이 답변 관련 질문 How to read the bit rate information from a .mov video file header
매우 좋은 & 근무 코드 주셔서 감사합니다. ** Microsoft Shell Controls and Automation **은 ** Microsoft Shell Folder View Router (Windows 8.1의 경우)로 바뀌 었습니다 ** –
정보에 대한 Kamlesh의 감사의 말 - 답변과 Win 8의 다른 변경 사항에 추가했습니다. – Plutonix
당신은 셸 API를 사용하여 사용자가 원하는 경우 (http://stackoverflow.com/a/325659/2012417) –
를 [읽기/쓰기 '확장'파일 속성]을 볼 수 있습니다 참조 이 단어를 구체적으로 말하면, Word.Interop을 통해이 정보를 얻거나 설정할 수 있습니다. – Steve
@ 스티브, 아니, 타. 다양한 파일 형식이 필요합니다 ... 단어, PDF, RTF, XML 등 아마도 – Toby