Solved

Copy or move a file

Posted on 2000-04-12
4
178 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 150 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month3 days, 23 hours left to enroll

630 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