Page 1 of 1

COPY FILE issue

Posted: Wed May 04, 2016 12:12 am
by Jeff Barnes
Is there a way to copy a file that has a comma "," in the file name.

With COPY FILE &cSource TO &cDest I get a DOS Error 123.

I cannot control the original filename so I have to somehow work with the "," in the filename.

I will also need to be able to delete this file without generating an error.

Re: COPY FILE issue

Posted: Wed May 04, 2016 3:38 am
by Gale FORd
You might try
COPY FILE (cSource) TO (cDest)
or maybe
filecopy( cSource, cDest )

Re: COPY FILE issue

Posted: Wed May 04, 2016 12:49 pm
by Jeff Barnes
Hi Gale,

Same error :(

Re: COPY FILE issue

Posted: Wed May 04, 2016 2:37 pm
by Gale FORd
I wonder if the error is in source or destination definition. Can you change the destination name to one without comma?
COPY FILE (cSource) TO ('test.tst')
If it can copy to normal filename without error then you might have a work around.
Maybe filemove( cSource, 'test.tst' )

Re: COPY FILE issue

Posted: Wed May 04, 2016 3:11 pm
by rhlawek
Jeff, I don't have xharbour available to test with but the following code works in harbour.

Code: Select all

procedure main()

   local cSource := "te,st.prg"
   local cTarget := cSource + ".bak"

   if FileCopy( cSource, cTarget ) != 0
      ? "Copy okay"
   else
      ? "Copy failed."
   endif

   return
 
Robb

Re: COPY FILE issue

Posted: Wed May 04, 2016 4:03 pm
by Jeff Barnes
Thanks Robb ... unfortunately with xharbour I get "Copy Failed" :(

Re: COPY FILE issue

Posted: Wed May 04, 2016 6:06 pm
by karinha

Code: Select all

static cTarget := "c:\Five"

function CopyFiles()

   cTarget = AllTrim( cTarget )

   if ! File( cTarget )
      lMkDir( cTarget )
   endif

   LZCopyFile( "d:\Five\Five.lib", cTarget + "Five.lib" )

return nil
 

Re: COPY FILE issue

Posted: Wed May 04, 2016 10:06 pm
by Rick Lipkin
Jeff

I know with Sql you can put things in brackets .. perhaps

Copy file ( "[Some,File]" ) to ( "[ Some,Where ]" ) .. untested .. just a shot in the dark.

Rick Lipkin

Re: COPY FILE issue

Posted: Thu May 05, 2016 8:58 am
by nageswaragunupudi
Jeff Barnes wrote:Is there a way to copy a file that has a comma "," in the file name.

With COPY FILE &cSource TO &cDest I get a DOS Error 123.

I cannot control the original filename so I have to somehow work with the "," in the filename.

I will also need to be able to delete this file without generating an error.
This FWH function works with both xHarbour and Harbour

Code: Select all

? CopyFile( cSourceFile, cDestFile, 0 )

Re: COPY FILE issue

Posted: Thu May 05, 2016 5:30 pm
by Jeff Barnes
Thanks everyone. I got it working :)