안녕하세요.
이곳에 답변이 빨라.. 자주 이용하는데 꼭좀 부탁드립니다.
^^;
도스에 dir처럼 파일리스트 출력하고 싶어서.. 아래처럼했는데
출력은 되는데 꼭 파일하나씩 부족하게 출력되거든요.
어디에 문제가 있는지 좀 봐주세요.
typedef struct _FLIST
{
char FileName[MAXPATH];
}FLIST;
TList *FileList;
void __fastcall TFrmMain::FormCreate(TObject *Sender)
{
FileList = new TList;
if(FileList == NULL) return;
MakeFileList("c:\\*.*");
}
void __fastcall TFrmMain::FormClose(TObject *Sender, TCloseAction &Action)
{
delete FileList;
}
void __fastcall TFrmMain::MakeFileList(char *dirname)
{
FLIST *p;
struct ffblk file;
int done;
if(FileList->Count > 0) FileList->Clear();
done = findfirst(dirname, &file, 0xF7);
while(!done)
{
p = new FLIST;
if(p == NULL) return;
strcpy(p->FileName, file.ff_name);
FileList->Add(p); //파일리스트 추가
done = findnext(&file);
}
for(int i=0; i<FileList->Count; i++) delete p;
}
출력부분은 맞는것 같아서.. 않올리구요..
위에 리스트를 만드는 부분에 문제가 있는것 같은데 어떻게 해야 되는지 꼭 좀
가르쳐 주심 감사하겠습니다.
|