Results 1 to 4 of 4

Thread: Finding all files in a folder

  1. #1

    Finding all files in a folder

    I'm working on my map editor at the moment and I need the editor to load a list of all files in the objects directory (say 'C:\Editor\Objects') but can't for the life of me work out how to do it. I don't want to use a component, I need pure code (libraries are fine). There must be an easier way of doing this. It seems so simple yet I don't know how. Am I missing something glaringly obvious or what? Can anyone help?
    Isometric game development blog http://isoenginedev.blogspot.com/

  2. #2

    Finding all files in a folder

    Code:
    var
      Rec: TSearchRec;
      SearchResult: Integer;
    begin
      SearchResult := FindFirst('C:\MyObjects\*.obj', faAnyFile, Rec);
      while SearchResult = 0 do
      begin
        LoadFile('C:\MyObjects\' + Rec.Name); // Do something with the file we've just found
       SearchResult := FindNext(Rec);
      end;
    end;
    Ask me about the xcess game development kit

  3. #3

    Finding all files in a folder

    Chuck a FindClose in there too...
    "All paid jobs absorb and degrade the mind."
    <br />-- Aristotle

  4. #4

    Finding all files in a folder

    Ooops! Totally forgot about that.
    Ask me about the xcess game development kit

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •