Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Copy or move a file

Posted on 2000-04-12
4
Medium Priority
?
179 Views
Last Modified: 2010-04-04
Hello,
I need help  as usual, where I would like to lets say from a menu item
select copy and move a file to another
directory.Something like the Send To
from windows explorer.
An explanation would be well received
as well as code on how to achieve this.
1/ how to copy a file to another directory form a menu item labelled copy
file.
2/ how to move a file to another directory from a menu item labelled move
file.
Regards,
Frank
0
Comment
Question by:frw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
simonet earned 450 total points
ID: 2710208
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2710779
Or just use the win32 APIs CopyFile or MoveFile.

Regards, Madshi.
0
 

Author Comment

by:frw
ID: 2713933
Does anyone have an example using the
win32's copy or move file?
0
 
LVL 15

Expert Comment

by:simonet
ID: 2714851
Sure!

Given:
var
  SourceFileName, DEstinatioFileName : string;

Both vars receive the names of the source and destination files.

For CopyFile:


CopyFile(pchar(SourceFileName), pchar(DestinationFileName), TRUE);

The last paramter specifies if the Destination file is to be overwritten if it already exists. From the Win32 SDK:

"Specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds. "


Note: CopyFileEX is not supported by Win95.

For MoveFile:

MoveFileEx(pchar(SourceFileName), pchar(DestinationFileName), MOVEFILE_REPLACE_EXISTING);

The last flag specifies how the operation should proceed. For more info on that flag, please refer to the Win32 SDK help file installed with Delphi.

Yours,

Alex
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question