Solved

Find and copy some files...

Posted on 1998-05-30
4
161 Views
Last Modified: 2010-04-06
Help!
I want to find all the TXT-files (*.txt) in my TEMP-directory (c:\temp) and then copy them into another directory.
How can I fix that job? Please send me the source to do it...
Thanx!
SvR.
0
Comment
Question by:roosiedb
  • 2
4 Comments
 
LVL 3

Expert Comment

by:Matvey
ID: 1349291
Don't remember exactly, but go to the Delphi pages and find a component that searches for files. Then give it parameters and copy the found files using the Delphi file routines...

http://sunsite.icm.edu.pl/delphi/ 
http://www.delphideli.com/ 
http://torry.rimini.com/ 

I'll try to find exactly...
0
 

Author Comment

by:roosiedb
ID: 1349292
I don't want to use any components, I want to have some code to copy (for example) all the *.txt -files in a directory. This must be possible with some (I hope) simple code...
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1349293
-Components come with sources. The copyfile procedure (or some other name) in Delphi is simple too. So just look at the source of the component to knwo how to find all files...
0
 
LVL 7

Accepted Solution

by:
ahalya earned 20 total points
ID: 1349294
you use  FindFirst, FindNext functions and "CopyFile" winapi.
( Matvey: not all components come with their source :-)

Here goes a sample proc.
//copies all files with name source.* to destn.* IF no EXT is given.
//otherwise copies source to destin.

procedure TMainForm.CopyMultipleFiles(source, destn:string);

var s1, s2 : string;
    Attr, Result : integer;
    SearchRec : TSearchRec;

begin;
if pos('.', source) = 0 then Source := Source + '.*';

Result := FindFirst(Source,  Attr, SearchRec);
While Result = 0 do
  begin
  s1 := ExtractFilePath(Source) + SearchRec.Name;
  s2 := ChangeFileExt(Destn, ExtractFileExt(SearchRec.Name));
  if not CopyFile(pchar(s1), pchar(s2), false) then
     begin;
     ShowMessage('Error Copying File: ' + S1);
     exit;
     end;
  Result := FindNext(SearchRec);
  end;
FindClose(SearchRec);
end;

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 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

28 Experts available now in Live!

Get 1:1 Help Now