I have a section of code which copies a records file (“A”) to a location (“B”) as a sort of backup. After converting to API2 I am having a problem developing an exception handling system. I am particularly discouraged since I have strange lasterrorcode. The debuggers enters this section and B is to be deleted prior to being copied. On the delete its lasterrorcode for B switches to 101. However, after the file is copied to B, the lasterrorcode is still 101.
I usually use a test like this:
if DFilListB(i).lastErrorCode > 0 Then
but that will now fail.
Also
Catch err as ioexception
doesn’t catch that the file is actually missing.
Here is the code I am using for this one section. There are complementary arrays DFilListA and DFilListB. The Boolean rmoved is for announcing if the file can be copied without the “already exists” error.
This code is in a loop which I didn’t include.
If you can make suggestions that would be great.
[code]Var rmoved As Boolean = False
If DFilListB(i).Exists = False Then rmoved = True
If DFilListB(i).Exists And DFilListA(i).ModificationDateTime > DFilListB(i).ModificationDateTime Then
DFilListB(i).Remove
rmoved = True
End If//If DFilListB(i) <> Nil And
If rmoved And (DFilListB(i) = Nil Or DFilListB(i).Exists = False) Then
DFilListA(i).CopyFileTo(DFilListB(i))//s>>d
YdErrMssge = YdErrMssge + DFilListA(i).Name + " Copied" + EOL
End If
if DFilListB(i).lastErrorCode > 0 Then
MessageBox "Error Copying File " + DFilListA(i).Name + " Due To " + Str(DFilListB(i).lastErrorCode) + EOL
End If
Elseif DFilListA(i).lastErrorCode > 0 Then
MessageBox "Error Copying File " + DFilListA(i).Name + " Due To " + Str(DFilListA(i).lastErrorCode) + EOL
End If
End If//
End If
rmoved = False[/code]