Solved

Copy or move a file

Posted on 2000-04-12
4
171 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
  • 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now