Copy files with wild card

Copy files with wild card

Postby Jeff Barnes » Fri Dec 09, 2005 4: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
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby YamilBracho » Fri Dec 09, 2005 4: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
YamilBracho
 
Posts: 33
Joined: Mon Oct 17, 2005 11:56 pm
Location: Caracas, Venezuela

Postby James Bott » Fri Dec 09, 2005 5: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"
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Jeff Barnes » 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)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby James Bott » 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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

It works for me

Postby dutch » Sun Dec 11, 2005 3: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
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 33 guests