<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[My Visual Database — [Script] Search files]]></title>
		<link>https://myvisualdatabase.com/forum/viewtopic.php?id=4292</link>
		<atom:link href="https://myvisualdatabase.com/forum/extern.php?action=feed&amp;tid=4292&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in [Script] Search files.]]></description>
		<lastBuildDate>Wed, 23 May 2018 11:06:47 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[[Script] Search files]]></title>
			<link>https://myvisualdatabase.com/forum/viewtopic.php?pid=25249#p25249</link>
			<description><![CDATA[<p>Example, how to search files in the system.<br />Works beginning from version 4.5</p><br /><div class="codebox"><pre><code>procedure FindFiles(Path: string; FileName: string; ListFiles: TStringList);
var
  Search: TSearchObj;
begin
  Search := TSearchObj.Create;
  try
      if Length(Path)&gt;0 then
          if Path[Length(Path)]&lt;&gt;&#039;\&#039; then Path := Path + &#039;\&#039;;

      // find all files
      if Search.FindFirst(Path+FileName, faAnyFile) = 0 then
      begin
        repeat
          // add the files to the listbox
          ListFiles.Add(Path + Search.Name);
        until Search.FindNext &lt;&gt; 0;
      end;

      // Subdirectories/ Unterverzeichnisse
      if Search.FindFirst(Path + &#039;*.*&#039;, faDirectory) = 0 then
      begin
        repeat
          if ((Search.Attr and faDirectory) = faDirectory) and (Search.Name[1] &lt;&gt; &#039;.&#039;) then
            FindFiles(Path + Search.Name + &#039;\&#039;, FileName, ListFiles);
        until Search.FindNext &lt;&gt; 0;
        Search.FindClose;
      end;

  finally
      Search.Free;
  end;
end;


procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
    Files: TStringList;
begin
    Files := TStringList.Create;
    FindFiles(&#039;c:\folder\&#039;, &#039;filename.ext&#039;, Files); // also you can use mask for file name, like *.exe, or *.* for all files
    Form1.Memo1.Text := Files.Text;
    Files.Free;
end;</code></pre></div><br /><br /><p><strong>Project example:</strong></p>]]></description>
			<author><![CDATA[null@example.com (DriveSoft)]]></author>
			<pubDate>Wed, 23 May 2018 11:06:47 +0000</pubDate>
			<guid>https://myvisualdatabase.com/forum/viewtopic.php?pid=25249#p25249</guid>
		</item>
	</channel>
</rss>
