Solved

Copy or move a file

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
drawing animated level bar based on numbers 3 122
FMX and jaudiotracker playing memory stream 29 109
FMX TEdit KeyUp handler detecting  "enter" key 4 64
IP without any Dots 1 100
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

710 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