Solved

File copy error 75

Posted on 2000-04-17
12
334 Views
Last Modified: 2010-08-05
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
Comment
Question by:andcu
  • 6
  • 5
12 Comments
 

Author Comment

by:andcu
ID: 2723092
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
 
LVL 43

Expert Comment

by:TimCottee
ID: 2723143
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
 
LVL 32

Expert Comment

by:bhess1
ID: 2723474
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
 
LVL 32

Expert Comment

by:bhess1
ID: 2723536
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
 

Author Comment

by:andcu
ID: 2725763
I think the answers are no because:

1) The client machine is Windows 95.

2) It can be copied manually
0
 
LVL 32

Expert Comment

by:bhess1
ID: 2727405
But what is the actual value in the variable LocalDir?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:andcu
ID: 2746631
LocalDir = c:\cashr\audit
cashdir = c:\cashr
0
 
LVL 32

Expert Comment

by:bhess1
ID: 2748366
This is a long shot, but try setting the Localfile variable manually, e.g.

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

Does this work?
0
 
LVL 32

Accepted Solution

by:
bhess1 earned 200 total points
ID: 2748446
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
 

Author Comment

by:andcu
ID: 2750517
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
 

Author Comment

by:andcu
ID: 2750525
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
 
LVL 32

Expert Comment

by:bhess1
ID: 2751749
No problem - just glad I remembered the situation where that happened to me!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now