Solved

Copy or move a file

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Internet Explorer View Settings Question 15 111
Convert a string into a TDateTime 5 60
control image tags in a string ? 12 130
Breakpoint doesn't stop in my variable 3 27
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

770 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