Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 377
  • Last Modified:

File copy error 75

I am having problems copying a file locally.  What happens is, we have a piece of software which creates the JRN files in the CashDir.  It copies files to the ServerFile.  This copies OK but when it copies it from the CashDir to LocalDir it fails.  To put these variable names into context, the ServerFile is a directory on a server and the CashDir is, as I said, a local location where the file resides until this code is run.  The LocalDir is also a local directory which is a subfolder of CashDir.


Private Sub Timer1_Timer()

Dim JRNFile As String, ServerFile As String, Log As String, Destination As String

On Error GoTo ErrorHandler

'Label1 = Counter

If Counter <> 60 Then    ' SET BACK TO 60
    Counter = Counter + 1
    Exit Sub
End If

Counter = 1

File = LocalDir & "\" & "Backup.log"
Open File For Append As #2

'Download updates from server - **NOT CURRENTLY USED**

'File = UpdateDir & "/*"
'UpdFile = Dir(File)

'Do While UpdFile <> ""
'    ServerFile = UpdateDir & "/" & UpdFile
'    LocalFile = Updates & "/" & UpdFile
'    FileCopy ServerFile, LocalFile
'    Log = UpdFile & " updated " & Now
'    Print #2, Log
'    UpdFile = Dir
'Loop

'Get the journal files one by one and if they are not todays files
'then copy them to the server and to the save directory then
'delete the origninals.  All this is logged in Backup.log

File = CashDir & "\*.JRN"
JRNFile = Dir(File)

'Label2 = "Transferring ..."
DoEvents

Do While JRNFile <> ""
    If JRNFile <> TodaysFile Then
        Print #2, "Copying " & JRNFile
        Infile = CashDir & "\" & JRNFile
        ServerFile = ServerDir & "\" & Position & "\" & JRNFile
        Localfile = LocalDir & "\" & JRNFile
        Destination = ServerFile
        FileCopy Infile, ServerFile
        Log = JRNFile & " copied to server at " & Now
        Print #2, Log
        FileCopy Infile, Localfile 'Fails here
        Log = JRNFile & " copied locally at " & Now
        Print #2, Log
        Kill Infile
        Log = JRNFile & " deleted at " & Now
        Print #2, Log
    End If
    JRNFile = Dir
Loop

'Label2 = ""

AfterError:

Close #2

On Error GoTo 0

Exit Sub

ErrorHandler:

Print #2, "Encounter Error" & Err

If (Err = 75) Or (Err = 76) Or (Err = 52) Then
    Log = "Failed to copy to " & Destination & " at " & Now
    Print #2, Log
    'Label2 = "Failed " & Err
    Resume AfterError
Else
    Log = "Error " & ErrCode & " occured at " & Now
    Print #2, Log
    End
    'Label2 = "Failed " & Err
End If

End Sub

I have tried recreating the exe and installing it again.
0
andcu
Asked:
andcu
  • 6
  • 5
1 Solution
 
andcuAuthor Commented:
It would be useful to know that the filenames are made up from the physical position of the PC in this case 03 and then the date they were produced so.  If the file was created on the 10/04/2000 at computer 03 then the name would be 03100400.jrn
0
 
TimCotteeCommented:
andcu, is there any possibility that localfile is open in another process? Or that if it is an NT box that there are permissions set which prevent the user accessing the folder?
0
 
Brendt HessSenior DBACommented:
My best bet is that LocalDir is either access protected, or the Variable name is formed incorrectly.  

Check the permissions on the LocalDir directory, and ensure that the variable LocalDir doesn't have a terminal backslash - FileCopy doesn't like names like 'C:\Logs\History\\03100400.log'
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Brendt HessSenior DBACommented:
My best bet is that LocalDir is either access protected, or the Variable name is formed incorrectly.  

Check the permissions on the LocalDir directory, and ensure that the variable LocalDir doesn't have a terminal backslash - FileCopy doesn't like names like 'C:\Logs\History\\03100400.log'
0
 
andcuAuthor Commented:
I think the answers are no because:

1) The client machine is Windows 95.

2) It can be copied manually
0
 
Brendt HessSenior DBACommented:
But what is the actual value in the variable LocalDir?
0
 
andcuAuthor Commented:
LocalDir = c:\cashr\audit
cashdir = c:\cashr
0
 
Brendt HessSenior DBACommented:
This is a long shot, but try setting the Localfile variable manually, e.g.

  Localfile = "c:\cashr\audit\" & JRNFile

Does this work?
0
 
Brendt HessSenior DBACommented:
One other long shot, based on a vaguely remembered problem some years back:  Open your log file on a differently numbered channel.  Try #9.  If I recall correctly, the Filecopy uses a channel as well, and it may be conflicting.

0
 
andcuAuthor Commented:
All I can say is it worked.

I don't know about the other idea of hardcoding "c:\cashr\audit" because I didn't try it so apologies if your answer would have worked too.
0
 
andcuAuthor Commented:
Ahh!

That was lucky, I have just realised that both these suggestions came from you, bhess1.  That was lucky means you can have points for your time aswell as for your correct answer.
0
 
Brendt HessSenior DBACommented:
No problem - just glad I remembered the situation where that happened to me!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now