slim steve
05-21-2003, 02:16 AM
Hi,
I have a small problem with a file copying routine which I have written. The routine is supposed to list all the files in the folder on the drive L: (some 300 fiiles) and copy them to the local C: drive. It works ok until it finds more than one error (error code 53) and on finding a second error displays the error message box instead of writing it to file and closes the application.
Any ideas why this is doing this would be appreciated.
Slim
Private Sub Command1_Click()
'This section copies data from L: to c:
Dim dafeventlog As String, T As String
On Error GoTo daf_errorcode_AP003
Open "c:\logs\eventlog.txt" For Append As #1
Print #1, Date, Time, "Starting Warehousing copy to c:\whsdata"
Open "c:\daf\logs\dellno1warehousing.txt" For Output As #2
T = Dir("l:\tran320\hnature\data\*.*") 'Specify Path and get first file
Do 'loop until all files read
If T <> "" Then 'Make sure a file has been found
On Error GoTo point1
FileCopy "l:\tran320\hnature\data\" & T, "c:\whsdata\" & T 'copy the file
End If
point1:
Print #2, Date, Time, T, Err.Number, Err.Description
Err.Clear
T = Dir 'Get the next file
Loop Until T = "" 'If there is no next file exit loop
Print #1, Date, Time, "Warehousing to C:\whsdata completed"
Close #1
Close #2
Exit Sub
daf_errorcode_AP003:
Close #2
Print #1, Date, Time, "DAF Error code AP003, Error copying Data to c:\whsdata"
Close #1
End Sub
I have a small problem with a file copying routine which I have written. The routine is supposed to list all the files in the folder on the drive L: (some 300 fiiles) and copy them to the local C: drive. It works ok until it finds more than one error (error code 53) and on finding a second error displays the error message box instead of writing it to file and closes the application.
Any ideas why this is doing this would be appreciated.
Slim
Private Sub Command1_Click()
'This section copies data from L: to c:
Dim dafeventlog As String, T As String
On Error GoTo daf_errorcode_AP003
Open "c:\logs\eventlog.txt" For Append As #1
Print #1, Date, Time, "Starting Warehousing copy to c:\whsdata"
Open "c:\daf\logs\dellno1warehousing.txt" For Output As #2
T = Dir("l:\tran320\hnature\data\*.*") 'Specify Path and get first file
Do 'loop until all files read
If T <> "" Then 'Make sure a file has been found
On Error GoTo point1
FileCopy "l:\tran320\hnature\data\" & T, "c:\whsdata\" & T 'copy the file
End If
point1:
Print #2, Date, Time, T, Err.Number, Err.Description
Err.Clear
T = Dir 'Get the next file
Loop Until T = "" 'If there is no next file exit loop
Print #1, Date, Time, "Warehousing to C:\whsdata completed"
Close #1
Close #2
Exit Sub
daf_errorcode_AP003:
Close #2
Print #1, Date, Time, "DAF Error code AP003, Error copying Data to c:\whsdata"
Close #1
End Sub