*.bmp Dateinamen aus Ordnern herrauslesen



  • Hi

    Ich möchte dass in meiner "ComboBox1" in den "->Items" automatisch alle z.B. "*.bmp" Dateien in die Liste geladen werden.
    Den Ordner sollte man vorher irgendwo auswählen können, über einen "Button" oder anderweitig. Ich weiß nur leider nicht wie man das macht.

    Kann mir bitte jemand helfen?
    ...bin noch Anfänger ...

    Danke
    MfG Andi



  • Schau mal in die MSDN oder nutz die Suche.
    Das wurde schon beschrieben.

    Wenn dir das auch nicht hilft kannst du dich ja nochmal melden.



  • Sorry ich hab keine ahnung unter was ich da im C++Builder suchen soll =(.
    Die MSDN besitze ich nicht.



  • The following example uses an edit control, a button, a string grid, and seven check boxes. The check boxes correspond to the seven possible file attributes. When the button is clicked, the path specified in the edit control is searched for files matching the checked file attributes. The names and sizes of the matching files are inserted into the string grid.

    void __fastcall TForm1::Button1Click(TObject *Sender)
    
    {
      TSearchRec sr;
      int iAttributes = 0;
      StringGrid1->RowCount = 1;
      iAttributes |= faReadOnly * CheckBox1->Checked;
      iAttributes |= faHidden * CheckBox2->Checked;
      iAttributes |= faSysFile * CheckBox3->Checked;
      iAttributes |= faVolumeID * CheckBox4->Checked;
      iAttributes |= faDirectory * CheckBox5->Checked;
      iAttributes |= faArchive * CheckBox6->Checked;
      iAttributes |= faAnyFile * CheckBox7->Checked;
      StringGrid1->RowCount = 0;
      if (FindFirst(Edit1->Text, iAttributes, sr) == 0)
    
      {
        do
        {
          if ((sr.Attr & iAttributes) == sr.Attr)
          {
            StringGrid1->RowCount = StringGrid1->RowCount + 1;
            StringGrid1->Cells[1][StringGrid1->RowCount-1] = sr.Name;
            StringGrid1->Cells[2][StringGrid1->RowCount-1] = IntToStr(sr.Size);
          }
        } while (FindNext(sr) == 0);
        FindClose(sr);
      }
    }
    

    Hier nehm zwar ne Stringrid aber das ändern ist ja leicht.
    Dann noch schnell auf *.bmp prüfen fertig.



  • http://msdn.microsoft.com/ da findest du die MSDN. 😉



  • VIELEN DANK!!!!!!!!!!!!!!!

    =)!!!



  • hmm..

    aber irgendwie bin ich zu doof das richtige einzusetzen 😞
    wenn ich das alles bei mir einbaue funktioniert zwar das programm, aber es passiert nichts 😞

    sorry dass ich mich so anstell, aber ich kanns halt leider noch ned so gut... 😞



  • lese mit opendir, readdir und closedir das verzeichnis aus, dann gibts nen praktischen befehl "ExtractFileExt(AnsiString filename);"! Den benutzt du dann um die Endungen der aktuellen Datei auszulesen. Hoffe du kannst das mit DIR und dirent .
    Sonst könnte ich dir auch den ganzen Code schreiben, aber sinn ist doch, hier was selbst zu lösen, mit hilfe von tipps, nich wahr 🙂

    aber ich würd ihn dir schon schreiben wenn du den unbedingt brauchst!



  • ich versuche es
    werde mich melden wenn ichs ned schaff 😉


Anmelden zum Antworten