How to get sub folder names of a directory that also contain dots in the name?
<p>I am trying to populate a stringlist with all the folder names inside a directory.</p>

<p>Below is an extract of how I was able to do this:</p>

<pre><code>var
  SL: TStringList;
  SearchAttr: LongInt;
  SR: TSearchRec;
begin
  SL := TStringList.Create;
  try
    SearchAttr := (faDirectory);

    if FindFirst(Directory + '\*.', SearchAttr, SR) = 0 then
    begin
      try
        repeat
          if (SR.Attr and faDirectory) &lt;&gt; 0 then
          begin
            if (SR.Name &lt;&gt; '.') and (SR.Name &lt;&gt; '..') then
            begin
              SL.Add(Directory + SR.Name);
            end;
          end;
        until
          FindNext(Sr) &lt;&gt; 0;
        finally
          FindClose(SR);
        end;
      end;
    end;

    // do something with string list folder names      
  finally
    SL.Free;
  end;
end;
</code></pre>

<p>The parent folder which I was accessing contains 220 sub folders but the routine was only adding 216 folder names. After some comparing and debugging I noticed the 4 folder names which were not been added contained dots in the names.</p>

<p>To test I created a folder called "Test Folder" and inside I added 9 more new folders named:</p>

<blockquote>
  <ul>
  <li>Folder 1</li>
  <li>Folder 2</li>
  <li>Folder 3</li>
  <li>Folder 4</li>
  <li>Folder 5</li>
  <li>Folder .6</li>
  <li>Folder 7</li>
  <li>F.O.L.D.E.R 8</li>
  <li>Folder 9</li>
  </ul>
</blockquote>

<p>When using "Test Folder" as the parent directory, it only adds the following sub folders:</p>

<blockquote>
  <ul>
  <li>Folder 1</li>
  <li>Folder 2</li>
  <li>Folder 3</li>
  <li>Folder 4</li>
  <li>Folder 5</li>
  <li>Folder 7</li>
  <li>Folder 9</li>
  </ul>
</blockquote>

<p>I have been experimenting with <code>SR.Name &lt;&gt; '.'</code>, <code>SR.Name &lt;&gt; '..'</code> and <code>SR.Name[1] &lt;&gt; '.'</code> etc with no success.</p>

<p>How can I modify the code to allow folder names with dots in the name and add them to my stringlist?</p>

<p>Thanks</p>