Autor Thema: Anhänge mit Datum versehen  (Gelesen 915 mal)

Offline Chris_FFM

  • Frischling
  • *
  • Beiträge: 22
  • ....wir haben doch keine zeit.......
Anhänge mit Datum versehen
« am: 23.05.02 - 12:33:35 »
Hallo,
ich hänge über @Formel Dateien an.
Klappt alles wunderbar.
Jetzt will ich aber nicht nur die Datei anhängen sondern auch das Dateidatum  und die Dateigröße mit anhängen.
Wie geht das?

Danke Chris

« Letzte Änderung: 01.01.70 - 01:00:00 von 1034200800 »

Offline eknori

  • @Notes Preisträger
  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 11.728
  • Geschlecht: Männlich
Re: Anhänge mit Datum versehen
« Antwort #1 am: 23.05.02 - 13:18:32 »
ich glaube, mir Formeln kommst du da nicht weiter.
Habe hier eine kleine LS Class, die den Job macht
Gibt dir unterschiedliche Infos zum File; schau mal bei den Case Anweisungen nach

' das kommt in die Declaration section eines Buttons oder eine Script Bibliothek

Const INVALID_HANDLE_VALUE = -1
Const MAX_PATH = 260

Type FILETIME
     dwLowDateTime As Long
     dwHighDateTime As Long
End Type

Type WIN32_FIND_DATA
     dwFileAttributes As Long ' Dateiattribute
     ftCreationTime As FILETIME ' Erstellungsdatum
     ftLastAccessTime As FILETIME ' Letzter Zugriff
     ftLastWriteTime As FILETIME ' Letzte Speicherung
     nFileSizeHigh As Long ' Größe (Hi)
     nFileSizeLow As Long ' Größe (Lo)
     dwReserved0 As Long ' bedeutungslos
     dwReserved1 As Long ' bedeutungslos
     cFileName As String * MAX_PATH ' Dateiname
     cAlternate As String * 14 ' 8.3-Dateiname
End Type

Type SYSTEMTIME
     wYear As Integer
     wMonth As Integer
     wDayOfWeek As Integer
     wDay As Integer
     wHour As Integer
     wMinute As Integer
     wSecond As Integer
     wMilliseconds As Integer
End Type


Declare Function FileTimeToLocalFileTime Lib "kernel32" (lpFileTime As FILETIME, lpLocalFileTime As FILETIME) As Long
Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (Byval lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (Byval hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
Declare Function FindClose Lib "kernel32" (Byval hFindFile As Long) As Long
Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As Long
Declare Function SystemTimeToFileTime Lib "kernel32" (lpSystemTime As SYSTEMTIME, lpFileTime As FILETIME) As Long

Class FileInfo
     
     Public Function GetFileTimeInfo ( strPath As String , MODE As Integer ) As String
           
           Dim FileHandle As Long
           Dim FileData As WIN32_FIND_DATA
           Dim LocalFileTime As FILETIME
           Dim LocalSystemTime As SYSTEMTIME
           
           FileHandle = FindFirstFile(strPath & vbNullChar, FileData)
           Select Case MODE
                 
           Case 0
                 FileTimeToLocalFileTime FileData.ftLastAccessTime, LocalFileTime              
           Case 1
                 FileTimeToLocalFileTime FileData.ftLastWriteTime, LocalFileTime              
           Case 2
                 FileTimeToLocalFileTime FileData.ftCreationTime, LocalFileTime              
                 
           End Select
           
           FileTimeToSystemTime LocalFileTime, LocalSystemTime
           
           GetFileTimeInfo = _
           Left$(FileData.cFileName, Instr(FileData.cFileName, vbNullChar) - 1)  _
           & LocalSystemTime.wDay & "." _
           & LocalSystemTime.wMonth & "." _
           & LocalSystemTime.wYear & ", "_
           & LocalSystemTime.wHour & ":" _
           & Format$(LocalSystemTime.wMinute, "00") _
           & ":" & Format$(LocalSystemTime.wSecond, "00") & " Uhr"
           
           FindClose FileHandle
           
     End Function
     
     Public Function GetFileInfo ( strPath As String , MODE As Integer ) As String
           
           Dim FileHandle As Long
           Dim FileData As WIN32_FIND_DATA
           
           FileHandle = FindFirstFile ( strPath  & vbNullChar , FileData )
           
           If FileHandle <> INVALID_HANDLE_VALUE Then
                 
                 Select Case MODE
                       
                 Case 3
                       GetFileInfo = FileData.cFileName
                 Case 4
                       GetFileInfo = Cstr(FileData.nFileSizeLow)
                 Case 5
                       GetFileInfo = FileData.cFileName
                 Case 6
                       GetFileInfo = Cstr(FileData.dwFileAttributes)
                 Case 7
                       GetFileInfo = Cstr(FileData.cAlternate)
                       
                 End Select
           End If
           FindClose FileHandle
           
     End Function
     
End Class


Sub Click(Source As Button)
     Dim fl As New FileInfo
     strFile$ = "d:\agentcontrol.nsf"
     Msgbox fl.GetFileInfo ( strFile$ , 4 )
     Msgbox fl.GetFileTimeInfo ( strFile$ , 1 )
End Sub

« Letzte Änderung: 01.01.70 - 01:00:00 von 1034200800 »
Egal wie tief man die Messlatte für den menschlichen Verstand auch ansetzt: jeden Tag kommt jemand und marschiert erhobenen Hauptes drunter her!

Offline Chris_FFM

  • Frischling
  • *
  • Beiträge: 22
  • ....wir haben doch keine zeit.......
Re: Anhänge mit Datum versehen
« Antwort #2 am: 23.05.02 - 13:55:29 »
danke, werde ich mal versuchen :)
« Letzte Änderung: 01.01.70 - 01:00:00 von 1034200800 »

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz