여러 파일에서 메타 데이터에 액세스하려고합니다. 이미 메타 데이터를 가져 오는 코드가 있지만 다른 폴더에있는 여러 파일을 가져올 수 있어야합니다. 파일 형식은 모두 동일합니다. 이것이 가능한가? 그렇다면 현재 코드에 추가 할 수 있습니까?여러 위치의 여러 파일에서 메타 데이터 가져 오기
Eventaully, 모든 메타 데이터를 가져 와서 비교를 위해 데이터베이스로 보내고 싶습니다.
이것은 내가 한 위치에 한 파일에서 얻을하는 데 사용 발견 된 코드는 다음과 같습니다
Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports System.IO
Imports Shell32
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Main()
End Sub
Sub Main()
Dim FileName As String
FileName = "D:\Folder\Folder1\filename.pst"
Dim Properties As Dictionary(Of Integer, KeyValuePair(Of String, String)) = GetFileProperties(FileName)
For Each FileProperty As KeyValuePair(Of Integer, KeyValuePair(Of String, String)) In Properties
ListBox1.Items.Add(FileProperty.Value.Key & ": " & FileProperty.Value.Value)
Next
End Sub
Public Function GetFileProperties(ByVal FileName As String) As Dictionary(Of Integer, KeyValuePair(Of String, String))
Dim Shell As New Shell
Dim Folder As Folder = Shell.[NameSpace](Path.GetDirectoryName(FileName))
Dim File As FolderItem = Folder.ParseName(Path.GetFileName(FileName))
Dim Properties As New Dictionary(Of Integer, KeyValuePair(Of String, String))()
Dim Index As Integer
Dim Keys As Integer = Folder.GetDetailsOf(File, 0).Count
For Index = 0 To Keys - 1
Dim CurrentKey As String = Folder.GetDetailsOf(Nothing, Index)
Dim CurrentValue As String = Folder.GetDetailsOf(File, Index)
If CurrentValue <> "" Then
Properties.Add(Index, New KeyValuePair(Of String, String)(CurrentKey, CurrentValue))
End If
Next
Return Properties
End Function
End Class
예에서 파일 경로는 하드 코딩되어 있습니다. List 또는 문자열 배열에서 파일을 가져 와서 반복해야합니다. –