Sub Meldearchiv_SD_nach_USB()
Dim fso, fs, f, attr
Dim path, file, filepath, returnfilename
Dim pathnamesrc, pathnamedst
Dim filesrc, filedst
Dim pathsrc, pathdst
Dim filepathsrc, filepathdst
'Dim Header
Dim myDate, mydatefile
Dim appendix
Dim myYear, myMonth, myDay, myHour, myMinute, mySecond
Dim i
Dim Trennzeile, Zeilennummer
'*** Initialisierungen ***
Err.Clear
On Error Resume Next
'*** Zuweisungen ***
Set f = CreateObject("FileCtl.File")
Set fs = CreateObject("FileCtl.Filesystem")
'Set fso = CreateObject("Scripting.FileSystemObject")
'HmiRuntime.ActiveScreen.ScreenItems("Textfeld_1").text = Err.Description
'*** Datum ***
myYear = Year(Now)
If Month(Now)>9 Then
myMonth = Month(Now)
Else
myMonth = "0" & Month(Now)
End If
If Day(Now)>9 Then
myDay = Day(Now)
Else
myDay = "0" & Day(Now)
End If
If Hour(Now)>9 Then
myHour = Hour(Now)
Else
myHour = "0" & Hour(Now)
End If
If Minute(Now)>9 Then
myMinute = Minute(Now)
Else
myMinute = "0" & Minute(Now)
End If
If Second(Now)>9 Then
mySecond = Second(Now)
Else
mySecond = "0" & Second(Now)
End If
myDate = myYear & myMonth & myDay & "_" & myHour & myMinute & mySecond
'*** Datei kopieren ***
pathnamesrc = "Storage Card SD"
pathnamedst = "Storage Card USB"
pathsrc = "\" & pathnamesrc
pathdst = "\" & pathnamedst
filesrc = "Meldearchiv_csv0"
filedst = "Meldearchiv_csv0" & "_" & myDate
appendix = ".csv"
filepathsrc = pathsrc & "\" & filesrc & appendix
filepathdst = pathdst & "\" & filedst & appendix
path = pathdst
If fs.dir (pathdst) = pathnamedst Then
fs.setattr filepathsrc, 0
fs.FileCopy filepathsrc, filepathdst
HmiRuntime.ActiveScreen.ScreenItems("USB-Stick_Info").text = " Das Meldearchiv wurde kopiert. Dateiname: " & filedst
Delay(2)
StartLogging hmiAlarmLog,"Meldearchiv_csv"
Else
HmiRuntime.ActiveScreen.ScreenItems("USB-Stick_Info").text = " Das Kopieren ist fehlgeschlagen: kein Zielordner vorhanden!"
End If
' Verwendeten Speicher wieder freigeben
Set f = Nothing
Set fs = Nothing
End Sub