?
Solved

Copying files from a disk

Posted on 1997-03-30
5
Medium Priority
?
161 Views
Last Modified: 2010-04-06
Sorry Zodik, but my customer is still running win 3.1 so I think your nice and quick solution won't do the job here.
My mistake for not specifying the OS. Sorry,

I need to copy  files from several floppy disks. Files need to be
copied to the hard disk in the exact same directory structure as on
the disks. Kind like an installation program. Is there any easy way to
do this, API call or one line of code?
Kris De Decker
0
Comment
Question by:sirk033097
[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
  • 2
5 Comments
 

Accepted Solution

by:
zodik earned 50 total points
ID: 1335069
on win95/nt4 you can use SHFileOperation to let the explorer do the work for you.


procedure TForm1.Button1Click(Sender: TObject);
var
 F : TShFileOpStruct;
begin
 F.Wnd := Handle;    
 F.wFunc := FO_COPY;
 F.pFrom := 'A:\*.*';
 F.pTo := 'C:\TEMP\';
 F.fFlags := FOF_ALLOWUNDO or FOF_RENAMEONCOLLISION;
 if ShFileOperation(F) <> 0 then ShowMessage('Copy Failed');
end;


0
 

Author Comment

by:sirk033097
ID: 1335070
Edited text of question
0
 

Author Comment

by:sirk033097
ID: 1335071
Wrong OS still using 16 bit. But the answer would have been excellent if I would be running the 32 bit windows OS.
0
 

Expert Comment

by:zodik
ID: 1335072
then, only other solution, except for writing a lot of code, seems to be shelling out to xcopy.
try using something like this
WinExec('xcopy /S a:\*.* c:\temp'; SW_SHOWNORMAL);

you can also do a FindWindow loop to wait until the operation ends.
the problem with this approach is almost no error-handling.

if you go for code, then on this page
http://carbohyd.siobc.ras.ru/torry/VCLFR.HTM
in the Files & Drives section you will find a number of components that will do enumerating/copying for you.
Your code will have to glue them together.



0
 
LVL 1

Expert Comment

by:sleach
ID: 1335073
This won't do a whole structure, but you can use it to copy one file at a time.  CopyFile is a windows API function.

var
source, dest: string;

source := 'C:\document.txt';
dest := 'A:\document.txt';

CopyFile(pchar(source), pchar(dest), false);
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month12 days, 16 hours left to enroll

777 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