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

Copy file from 1 directory to another 1

Status
Not open for further replies.

Gandalf23

Programmer
Apr 9, 2002
128
NL
Hello all,

Does anyone know the a function to copy one file from a directory to another, regardless of its type.

Greetings,

Gandalf.
 
HI
** If you want to copy a folder to another folder..
mySource = GETDIR("*.*","Select Source Directory","")+"*.*"
myDestination = GETDIR("*.*","Select Destination Directory","")
RUN /N XCOPY &mySource &myDestination /S

** If you want to copy only a file..
Use GETFILE() in the above in the place of myDource GETDIR

:) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
You can use the "built-in" COPY FILE command.

Rick
 
According to the help file:

Duplicates any type of file.

COPY FILE FileName1 TO FileName2
 
Thanks all,

I prefer the first one but Ramani isn't it better to use () instead of a macro substitution? For instance if a file has a space in its name.

I learned not to use macro substitutions because of all the anger my customers got when the used it for a name with space. Just a tip.

Greetings,

Gandalf.
 
Gandalf,
Ramani's will work, if you just add "'s around the Macros. i.e.
RUN /N XCOPY "&mySource" "&myDestination" /S

Rick
 
Yes indeed it works. Good to know. A star for Ramani...
 
BTW, You can't use () instead of macro substitution in a RUN command... everything after RUN/N is taken literally, except for macro subs.

ie:
Code:
Command = "DIR *.*"
RUN (Command)
is the same at typing "(Command)" at the DOS prompt,
while
Code:
Command = "DIR *.*"
RUN &Command
is the same at typing "DIR *.*" at the DOS prompt.

 
Is there a command in vfp that replace the dos command (COPY). There must be one somewhere. I don't want to issue the run command. any ideas will help. thanks.
 
Yes. mgagnon mentioned it above. To copy all files from c:\windows to c:\winback, you would do this:
[tt]
IF !DIRECTORY("c:\winback")
MKDIR c:\winback
ENDIF

COPY FILE
c:\windows\*.* TO c:\winback
[/tt]
Ian
 
AChiado

No - you need DOS commands xcopy.exe or xcopy32.exe plus switches.

You can run them hidden with WinAPI calls or WSH script HTH

Chris [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top