FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Copy files with wild card
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Copy files with wild card
Posted: Fri Dec 09, 2005 04:12 PM

Hi,

I there a way to copy files from within FWH allowing wild cards.

I am tring to do something like:

cFileSource := "F:\Myfile."
cFileDest := "C:\MyFolder\"

Copy File &cFileSource to &cFileDest

but I get a Open error for cFileSource

Thanks,
Jeff

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 33
Joined: Mon Oct 17, 2005 11:56 PM
Copy files with wild card
Posted: Fri Dec 09, 2005 04:46 PM

Get the files in the source path using Directory, then use an loop or aeval and do the copy, one file at once

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Copy files with wild card
Posted: Fri Dec 09, 2005 05:33 PM

I haven't tried it, but this might work.

copyFile(cSource,cTarget,nFailIfExists)

Where nFailIfExists = 0 overwrite if cTarget exists
1 fail if cTarget exists

DLL32 FUNCTION CopyFile( Source_file AS LPSTR, Target_file AS
LPSTR,; Ret_err AS LONG ) AS BOOL FROM "CopyFileA" LIB
"Kernel32.dll"

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Copy files with wild card
Posted: Fri Dec 09, 2005 11:01 PM

Thanks Yamil and James,

James, I tried your soultion but it forced my app to quit (without any error being generated)

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Copy files with wild card
Posted: Sat Dec 10, 2005 10:41 PM

Jeff,

Before I gave up I would check to see if it works without a wildcard. It worked for me, but I can't remember, perhaps I only used it in 16bit apps.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
It works for me
Posted: Sun Dec 11, 2005 03:31 PM

Dear Jeff,

This is an example that work for me.

Regards,
Dutch


aFiles1 = directory(".db?")
aFiles2 = directory("
.fpt")

if !empty(aFiles1)

aTarget:= {}
aSource:= {}

for n := 1 to len(aFiles1)
aadd(aTarget,DayOfWeek+'\'+aFiles1[n][1])
aadd(aSource,aFiles1[n][1])
next
for n := 1 to len(aFiles2)
aadd(aTarget,DayOfWeek+'\'+aFiles2[n][1])
aadd(aSource,aFiles2[n][1])
next

copyfiles( aSource, aTarget )

endif

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)

Continue the discussion