Lupus Goebel
2006-11-28 22:57:05 UTC
Hallöschen,
gibt es eine elegante Möglichkeit den Dateityp einer Datei auszulesen?
Bisher lese ich mit dem Code:
\\\
Private Type strFile
tName As String
dDate As Date
dSize As Double
dTyp As String
End Type
Function ReadFolder(strLWPfad As String)
Dim fso As Scripting.FileSystemObject
Dim f As Scripting.Folder
Dim d As Scripting.File
Dim ds As Scripting.Files
Dim i As Long, n As Long
Dim da() As strFile
Dim j As Long, tmp As strFile
Dim strEinleseDateiArt As String
Dim rs As Recordset
Set fso = New Scripting.FileSystemObject
Set f = fso.GetFolder(strLWPfad)
Set ds = f.Files
n = ds.count
If n > 0 Then
ReDim da(1 To n)
For Each d In ds
Set rs = CurrentDb.OpenRecordset("tblImportliste")
rs.AddNew
rs.Fields("DateiName").Value = d.Name
rs.Fields("DateiDatum").Value = d.DateLastModified
rs.Fields("Groesse").Value = d.Size
rs.Fields("dateipfad") = strLWPfad
rs.Fields("Dateityp") = d.Type
rs.Update
rs.Close
Set rs = Nothing
Next d
End If
Set ds = Nothing
Set f = Nothing
Set fso = Nothing
End Function
////
Es wird zwar der Dateityp angegeben, das sieht dann aber so aus:
Dateityp
HTML Document
Adobe Acrobat 7.0 Document
Cascading Style Sheet-Dokument
IrfanView PNG File
Mit dem Dateityp muss ich Verknüpfungen machen. Was nun aber wenn ein
User anstelle Adobe Acrobat 7 eben Adobe Acrobat *5* hat?
Daher suche ich nach einer Möglichkeit die mir eben *pdf* oder *asp*
etc. ausgibt.
Erster Gedanke, suche im Dateinamen nach einem Punkt und gebe mir das
aus was rechts davon steht.
Cool, meine Kollegen haben solche Dateinamen: "20.11.2006.xls"
Nun, nennt mir bitte ein paar Stichwörter, damit weiss wonach ich suchen
muss.
gibt es eine elegante Möglichkeit den Dateityp einer Datei auszulesen?
Bisher lese ich mit dem Code:
\\\
Private Type strFile
tName As String
dDate As Date
dSize As Double
dTyp As String
End Type
Function ReadFolder(strLWPfad As String)
Dim fso As Scripting.FileSystemObject
Dim f As Scripting.Folder
Dim d As Scripting.File
Dim ds As Scripting.Files
Dim i As Long, n As Long
Dim da() As strFile
Dim j As Long, tmp As strFile
Dim strEinleseDateiArt As String
Dim rs As Recordset
Set fso = New Scripting.FileSystemObject
Set f = fso.GetFolder(strLWPfad)
Set ds = f.Files
n = ds.count
If n > 0 Then
ReDim da(1 To n)
For Each d In ds
Set rs = CurrentDb.OpenRecordset("tblImportliste")
rs.AddNew
rs.Fields("DateiName").Value = d.Name
rs.Fields("DateiDatum").Value = d.DateLastModified
rs.Fields("Groesse").Value = d.Size
rs.Fields("dateipfad") = strLWPfad
rs.Fields("Dateityp") = d.Type
rs.Update
rs.Close
Set rs = Nothing
Next d
End If
Set ds = Nothing
Set f = Nothing
Set fso = Nothing
End Function
////
Es wird zwar der Dateityp angegeben, das sieht dann aber so aus:
Dateityp
HTML Document
Adobe Acrobat 7.0 Document
Cascading Style Sheet-Dokument
IrfanView PNG File
Mit dem Dateityp muss ich Verknüpfungen machen. Was nun aber wenn ein
User anstelle Adobe Acrobat 7 eben Adobe Acrobat *5* hat?
Daher suche ich nach einer Möglichkeit die mir eben *pdf* oder *asp*
etc. ausgibt.
Erster Gedanke, suche im Dateinamen nach einem Punkt und gebe mir das
aus was rechts davon steht.
Cool, meine Kollegen haben solche Dateinamen: "20.11.2006.xls"
Nun, nennt mir bitte ein paar Stichwörter, damit weiss wonach ich suchen
muss.
--
MfG - Lupus Goebel
Der Sumpf- und Morasthobbybastler und Anfaenger mit
Wissensdurst (http://www.lupusdw.de)
Meine private FAQ http://www.lupusdw.de/faq
MfG - Lupus Goebel
Der Sumpf- und Morasthobbybastler und Anfaenger mit
Wissensdurst (http://www.lupusdw.de)
Meine private FAQ http://www.lupusdw.de/faq