|
원하는 디렉토리안의 파일들을 찾아내는 방법을 원하시는 듯 합니다. 디렉토리 안의 파일들의 목록을 알게 되면 당연히 각 파일별로 전송을 반복하시면 될 듯 하네요.
TSearchRec, FindFirst, FindNext, FindClose 를 사용해서 원하시는 디렉토리 안의 파일, 하위 디렉토리를 읽어올 수 있습니다.
Delphi Help 파일에서 해당 예제를 복사했습니다. Edit1->Text가 원하는 디렉토리를 가리키는 것으로 기억합니다.
더 필요한 내용은 검색을 해보시면 어떨까 생각되네요.
-------------------------------------------------------------------------------------------------
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);
}
}
-------------------------------------------------------------------------------------------------
김민재 님이 쓰신 글 :
: 요즘 소켓으로 파일을 주고받는 프로그램짜고 있습니다...
: 파일을 전송건 돼는데....
: 폴더와 폴더안의 파일을들 전송한는건 도데체 모르겠습니다...
: 어떻게 해야하는지요?,,,불가능한건 아니겟죠?....^^;..
: 잘하시는 분들의 조언 부탁드립니다....
: 또 예제나 샘플프로그램 있으면 부탁드립니다....
: 그럼 수고하세요....
|