Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 7th, 2010, 10:29 PM   #1
MrFailboat1990
Newbie
 
Join Date: Mar 2010
Posts: 4
Rep Power: 0 MrFailboat1990 is on a distinguished road
Performing a file search, and then uploading results to a backup server

hi

i am writing a program for a client to upload files related to his management software to a backup FTP on the local network.

I am using Indy Componenents to make the FTP Connection, i have a TidFTP component on the form with all the FTP connection information in.

The Form succesfully connects/disconnects and uploads single files to the FTP.

i need to know how to write code to perform a search for files with the extension of .RGPJ on Local Drive X:\
and then upload the found files to the server.

i can upload a single RGPJ file using
IDFtp1.Put('LocalFile', 'RemoteFile');

but im stuck for searching for multiple files and uploading them.

anybody out here kind enough to shed some light on the subject?
MrFailboat1990 is offline   Reply With Quote
Old Mar 7th, 2010, 10:45 PM   #2
abdul.gafur
Trying to be a Real Coder
 
abdul.gafur's Avatar
 
Join Date: Feb 2010
Location: Salo, Riau, Indonesia
Posts: 112
Rep Power: 1 abdul.gafur is on a distinguished road
Send a message via Yahoo to abdul.gafur
Re: Performing a file search, and then uploading results to a backup server

Please visit :
__________________
just a drop of dew in the morning
abdul.gafur is offline   Reply With Quote
Old Mar 8th, 2010, 10:34 AM   #3
MrFailboat1990
Newbie
 
Join Date: Mar 2010
Posts: 4
Rep Power: 0 MrFailboat1990 is on a distinguished road
Re: Performing a file search, and then uploading results to a backup server

hi

i still dont have exactly what i need but i think im close now, the code im using for the search is below.

procedure FindAll (const Path: String;
                          Attr: Integer;
                          List: TStrings) ;
var
   Res: TSearchRec;
   EOFound: Boolean;
begin
   EOFound:= False;
   if FindFirst(Path, Attr, Res) < 0 then
     exit
   else
     while not EOFound do begin
       List.Add(Res.Name) ;
       EOFound:= FindNext(Res) <> 0;
     end;
   FindClose(Res) ;
end;

and to search im using

FindAll('X:\Test\*.rgpj*',faAnyFile,ListBox1.Items);

however this code i have only seems to list files in the current directory, i need a function that searches the entire drive including subfolders etc, and then lists all the .rgpj files it finds.

http://www.festra.com/eng/snip04.htm

the procedure listed on there i actually cannot get to return any results at all when im testing it.

would somebody mind helping me out with writing my own function to search for the files i need over an entire drive.
MrFailboat1990 is offline   Reply With Quote
Old Mar 8th, 2010, 8:22 PM   #4
abdul.gafur
Trying to be a Real Coder
 
abdul.gafur's Avatar
 
Join Date: Feb 2010
Location: Salo, Riau, Indonesia
Posts: 112
Rep Power: 1 abdul.gafur is on a distinguished road
Send a message via Yahoo to abdul.gafur
Re: Performing a file search, and then uploading results to a backup server

delphi Syntax (Toggle Plain Text)
  1. // Recursive procedure to build a list of files
  2. procedure FindFiles(FilesList: TStringList; StartDir, FileMask: string);
  3. var
  4. SR: TSearchRec;
  5. DirList: TStringList;
  6. IsFound: Boolean;
  7. i: integer;
  8. begin
  9. if StartDir[length(StartDir)] <> '\' then
  10. StartDir := StartDir + '\';
  11.  
  12. { Build a list of the files in directory StartDir
  13.   (not the directories!) }
  14.  
  15. IsFound :=
  16. FindFirst(StartDir+FileMask, faAnyFile-faDirectory, SR) = 0;
  17. while IsFound do begin
  18. FilesList.Add(StartDir + SR.Name);
  19. IsFound := FindNext(SR) = 0;
  20. end;
  21. FindClose(SR);
  22.  
  23. // Build a list of subdirectories
  24. DirList := TStringList.Create;
  25. IsFound := FindFirst(StartDir+'*.*', faAnyFile, SR) = 0;
  26. while IsFound do begin
  27. if ((SR.Attr and faDirectory) <> 0) and
  28. (SR.Name[1] <> '.') then
  29. DirList.Add(StartDir + SR.Name);
  30. IsFound := FindNext(SR) = 0;
  31. end;
  32. FindClose(SR);
  33.  
  34. // Scan the list of subdirectories
  35. for i := 0 to DirList.Count - 1 do
  36. FindFiles(FilesList, DirList[i], FileMask);
  37.  
  38. DirList.Free;
  39. end;
  40.  
  41. // Example: how to use FindFiles
  42. procedure TForm1.ButtonFindClick(Sender: TObject);
  43. var
  44. FilesList: TStringList;
  45. begin
  46. FilesList := TStringList.Create;
  47. try
  48. FindFiles(FilesList, EditStartDir.Text, EditFileMask.Text);
  49. ListBox1.Items.Assign(FilesList);
  50. LabelCount.Caption := 'Files found: ' + IntToStr(FilesList.Count);
  51. finally
  52. FilesList.Free;
  53. end;
  54. end;
source : http://www.festra.com/eng/snip04.htm

FindFiles is recursive. See part of FindFIles' code
// Scan the list of subdirectories
for i := 0 to DirList.Count - 1 do
FindFiles(FilesList, DirList[i], FileMask);


It is for search the entire folders
__________________
just a drop of dew in the morning
abdul.gafur is offline   Reply With Quote
Old Mar 8th, 2010, 10:11 PM   #5
MrFailboat1990
Newbie
 
Join Date: Mar 2010
Posts: 4
Rep Power: 0 MrFailboat1990 is on a distinguished road
Re: Performing a file search, and then uploading results to a backup server

hi

when my application is using the search function i cannot move my application window or interact with any other button.

how can i make my application responsive while it is searching for files in the background.
MrFailboat1990 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:01 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC