Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Denied error when using COPY() 1

Status
Not open for further replies.

rleiman

Programmer
May 3, 2006
258
US
Hi Everyone,

Can you tell me what is wrong with my code? I get an Access Denied error when trying to backup the tps database files.

Thanks.
Emad

Code:
If FILEDIALOGA('Please tell me where to backup your data:', LOC:FilePath, '', 48) |
Then
   COPY(Path() & '/*.TPS', LOC:FilePath)

   If Not Error() |
   Then
      Message ('Your data has been successfully backed up.')
   Else
      Message (Error())
   End
End
 
Hi Emad,

You need to use a back slash (\*.tps) instead of a front slash (/*.tps).

Regards
 
Hi ShankarJ,

ooooooooooooooooooooopppppppppppsssssssssssss!!!!!!!!!!!!!

Thanks.

I will give it a try.

Truly,
Emad
 
Hi!

Please also check that :

1) the path in LOC:FilePath exists
2) you have access to that path

Also use the flag equates FILE:KeepDir+FILE:LongName+FILE:Directory instead of 48. Also 48 should be 50 to include the FILE;KeepDir which makes sure that your current path is not lost. Maybe this is why it is failing because the PATH() is returning the same value as LOC:FilePath i.e. you are trying to copy to the same directory.

Regards
 
Hi ShankarJ,

The Access Denied errors still comes up.

I also checked PATH() and LOC:FilePath and PATH() returns my current path except it puts the ~1 characters instead of the real folder name. LOC:FilePath returns the full folder name I choose from the dialoge box.

I thought that running the application locks the files because they are in use, but I tried to copy some worksheet files and got the same error.

Thanks.
Emad
 
Hi.

I you can, can you place the code I tried in a button and see if the code works?

Thanks.

Truly,
Emad
 
Hi Emad,

COPY() is meant to copy A file. Not sure if it will work with multiple ones.

An alternative is to use :

RUN('COMMAND.COM /C COPY ...') OR
RUN('CMD.COM /C COPY ...')

PATH() returns Short File Names. LONGPATH() is the alternative to get Long File Path Names.

Regards
 
Hi ShankarJ,

Thanks for the help.

I will try it tonight.

Truly,
Emad
 
Hi.

I had a problem using the run command because it just opened and quickly close the dos window so I made many copy commands for each individual topspeed table.

Thanks.

Truly,
Emad
 
Hi Emad,

You can possibly use DIRECTORY() to get the list of TPS files into a Queue and then copy the files one by one.

Regards
 
Hi ShankarJ,

I have not done custom coding of queues since I let the ide mostly do the coding for me.

Can you give me example code, how and where to implement it? (only if you have the time to do it since my clunky version is working)

Thanks.

Truly,
Emad
 
Hi Emad,

Define a Queue in the Data Section embed :

Code:
TPSFiles                     QUEUE(FILE:Queue),PRE(TPS)
                             END

The Code :

Code:
DIRECTORY(TPSFiles, CLIP(DataPath) & '*.TPS', 0) ! Load the Queue

IF RECORDS(TPSFiles)
   LOOP F# = 1 to RECORDS(TPSFiles)
      GET(TPSFiles, F#)

      COPY(CLIP(DataPath) & TPS:Name, CLIP(ArchivePath) & TPS:Name)
      IF ERRORCODE()
         MESSAGE(ERROR() & ' [' & ERRORCODE() & ']', 'E R R O R  - ' & TPS:Name)
      END
   END
ELSE
   MESSAGE('No TPS Files to Process')
END

Make sure that the DataPath and ArchivePath variables end in a backslash (\).

Regards
 
Hi ShankarJ,

Thanks for the code.

I love it because I don't have to hard code the file names!

I will implement it.

Thanks again.

Truly,
Emad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top