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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy 1

Status
Not open for further replies.

berthoud

Technical User
Oct 31, 2010
51
FR
Hello,

Is't possible with c5ee (or c6) to copy a file (a picture jpg,gif or other) selected with the DosFileLookUp Template from a path to another.

Is "COPY" command works only for the files of the dictionnary?????

Thanks for your help

Have a good day
 
Hi!

COPY should work fine with non-dictionary files. The example from the C6 help is given below ::

Code:
FromFolder  CSTRING(250)
ToFolder    CSTRING(250)
TheFile     STRING(256),STATIC
SomeFile FILE,DRIVER('DOS'),NAME(TheFile)
Record    RECORD
F1         STRING(1)
          END
         END
 CODE
 TheFile = 'Names.DAT'
 COPY(TheFile,'A:\')                       !Copy file to floppy
 COPY('C:\AUTOEXEC.BAT','A:\AUTOEXEC.BAT') !Copy file to floppy
 FromFolder = 'z:\my folder\file1.tps'
 ToFolder = 'z:\backup area' !Use double quotes to handle folders with spaces

 COPY(FromFolder,ToFolder)

Regards
 
Hi!

If you HAVE USED Window API's before in Clarion, I can give you an example of it's usage for File Copying although the inbuilt COPY is good enough.

Regards
 
I try this example with no success.

I try again and again next days
 
Hi!

Post your code. Are you checking for errors? If so, what errors are you getting?

Also, what OS are you using since with Vista/7 you have to consider UAC issues?

Regards
 
Thanks for your help

My tests

ControlEventHandling,before generated code
?LookUpFile - Accepted

DestinationPath=clip(Path())&'\Photos\'

ControlEventHandling,after generated code
?LookUpFile - Accepted

message(clip(REP:photo)&' - '&clip(DestinationPath)) !Debug => OK but DestinationPath is on "short mode"

COPY(clip(REP:photo),clip(DestinationPath)) => don't works
if errorcode() then stop(error()). => no error

an other way

COPY(clip(REP:photo),clip(DestinationPath)&'*.*') =>don't works
if errorcode() then stop(error()). => error "Acces denied
 
Hi!

The first way looks OK to me.

The second way (using *.*) is wrong.

Does REP:photo contain a proper path and file name?

You can always get the full path (long mode) by using LONGPATH() i.e. LONGPATH(PATH()) & '\Photos\'.

If you want to try the API approach, here is it ::

Code:
GLOBAL embeds, Before File Declarations ::
!
! Shell File Operations
!
FO_MOVE                    EQUATE(0001h)
FO_COPY                    EQUATE(0002h)
FO_DELETE                  EQUATE(0003h)
FO_RENAME                  EQUATE(0004h)

FOF_MULTIDESTFILES         EQUATE(0001h)
FOF_CONFIRMMOUSE           EQUATE(0002h)
FOF_SILENT                 EQUATE(0004h)  ! don't create progress/report
FOF_RENAMEONCOLLISION      EQUATE(0008h)
FOF_NOCONFIRMATION         EQUATE(0010h)  ! Don't prompt the user.

! Fill in SHFILEOPSTRUCT.hNameMappings
! Must be freed using SHFreeNameMappings
FOF_WANTMAPPINGHANDLE      EQUATE(0020h)
FOF_ALLOWUNDO              EQUATE(0040h)
FOF_FILESONLY              EQUATE(0080h)  ! on *.*, do only files
FOF_SIMPLEPROGRESS         EQUATE(0100h)  ! means don't show names of files
! don't confirm making any needed dirs
FOF_NOCONFIRMMKDIR         EQUATE(0200h)
FOF_NOERRORUI              EQUATE(0400h)  ! don't put up error UI
! dont copy NT file Security Attributes
FOF_NOCOPYSECURITYATTRIBS  EQUATE(0800h)
FOF_NORECURSION            EQUATE(1000h)  ! don't recurse into directories.
! don't operate on connected elements.
FOF_NO_CONNECTED_ELEMENTS  EQUATE(2000h)
! during delete operation, warn if nuking instead of recycling
! (partially overrides FOF_NOCONFIRMATION)
FOF_WANTNUKEWARNING        EQUATE(4000h)

SHFILEOPgroup         GROUP, TYPE
hwnd                    UNSIGNED
wFunc                   UNSIGNED
pFrom                   LONG
pTo                     LONG
fFlags                  USHORT
fAnyOperationsAborted   LONG
hNameMappings           LONG
lpszProgressTitle       LONG
                      END

!==========================================================

GLOBAL embeds, Inside the Global Map ::

MODULE('Windows.lib')
  SHFileOperation(LONG pSHFILEOPgroup), LONG, PASCAL, |
    RAW, DLL,NAME('SHFileOperationA')
END

!==========================================================

Data (in Procedure) ::

SHFileOp    LIKE(SHFILEOPgroup)
Source      CSTRING(256)
Destination CSTRING(256)

!==========================================================

Insert this code where you want to perform the copy:

! This copies an entire directory - note the terminating <0>
Source = 'C:\TheSourceDirectory\*.*' & '<0>'
! This would copy 2 files
! The filenames are separated by <0>
! The list is terminated by <0><0>
Source = 'file1.exe<0>file2.exe<0><0>
Destination = 'C:\TheDestinationDirectory'

CLEAR(SHFileOp)
SHFileOp.hWnd   = 0{PROP:Handle}
SHFileOp.wFunc  = FO_COPY
SHFileOp.pFROM  = ADDRESS(Source)
SHFileOp.pTo    = ADDRESS(Destination)
SHFileOp.fFlags = FOF_NOCONFIRMATION + FOF_NOCONFIRMMKDIR

SHFileOperation(ADDRESS(SHFileOp))

Regards
 
?????? I post a reply Yesterday but I don't see this post.

The copy works fine in C5 with longpath().

Many, many, thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top