Solved

File copy error 75

Posted on 2000-04-17
12
346 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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
 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

821 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