C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[13202] Re:Re:Re:하위 폴더들 정보 얻어오기
지나가는 사람 [] 1534 읽음    2001-11-28 15:51
빌더에서 FindFirst 치고 F1을 눌러봤습니다. --;
Example까지 있네요..
------------------------------------------------------
Searches for the first instance of a file name with a given set of attributes in a specified directory.

Unit

Sysutils

Category

file management routines

extern PACKAGE int __fastcall FindFirst(const AnsiString Path, int Attr, TSearchRec &F);

Description

FindFirst searches the directory specified by Path for the first file that matches the file name implied by Path and the attributes specified by the Attr parameter. The result is returned in the F parameter. Use the fields of this search record to extract the information needed. FindFirst returns 0 if a file was successfully located, otherwise, it returns a Windows error code.

The Path constant parameter is the directory and file name mask, including wildcard characters. For example, 밹:\test\*.*
?specifies all files in the C:\TEST directory).

The Attr parameter specifies the special files to include in addition to all normal files. Choose from these file attribute constants when specifying the Attr parameter:

Constant    Value    Description

faReadOnly    $00000001    Read-only files
faHidden    $00000002    Hidden files
faSysFile    $00000004    System files
faVolumeID    $00000008    Volume ID files
faDirectory    $00000010    Directory files
faArchive    $00000020    Archive files
faAnyFile    $0000003F    Any file

Attributes can be combined by or-ing their constants or values. For example, to search for read-only and hidden files in addition to normal files, pass (faReadOnly | faHidden) as the Attr parameter.

Note:    FindFirst allocates resources (memory) which must be released by calling FindClose.


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);
  }
}

Hee 님이 쓰신 글 :
: 정말 잘몰라서 그러는데요...
: 조금더 자세히 알려주시면 안될까요...??
:
:
:
: 지나가는 사람 님이 쓰신 글 :
: :
: : 이건 답을 쉽게 찾을 수 있는건데...  쩝...
: :
: : C언어 책에서 한번 찾아보세요..
: :
: : 제 기억이 정확하다면..  FindFirst와 FindNext를 이용하면 됩니다.
: : 이때.. 속성을 디렉토리로 지정하면 됩니다.
: :
: : 이건 도스때도 쓰던거니까.. 아무 C언어 책같은데 잘 찾아보면 있을겁니다.
: : 아마도 헬프에도 있을거구요..
: :
: :
:

+ -

관련 글 리스트
13197 하위 폴더들 정보 얻어오기 Hee 1182 2001/11/28
13199     Re:하위 폴더들 정보 얻어오기 지나가는 사람 1205 2001/11/28
13200         Re:Re:하위 폴더들 정보 얻어오기 Hee 959 2001/11/28
13202             Re:Re:Re:하위 폴더들 정보 얻어오기 지나가는 사람 1534 2001/11/28
13204                 Re:Re:Re:Re:^.^~ Hee 842 2001/11/28
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.