2

When i was testing the following code,i found that "data.cFileName" in "FtpFindFirstFile" was "." on some ftp,and on others,it was an actural file name.In the second case,"InternetFindNextFile" began with the second file.I just want to know why does this happen?Thanks!

if(hConnect){
            cout<<"begin transfer……"<<endl;
            find=::FtpFindFirstFile(hConnect,ftpDir,&data,INTERNET_FLAG_RELOAD,0);
            cout<<"begin?-->"<<data.cFileName<<endl;
            while(::InternetFindNextFile(find,&data)){
                CString tempFtp=ftpDir;
                CString tempLocal=localDir;
                cout<<"file:"<<data.cFileName<<endl;
                //dirArray.SetSize(10);
                /*
                if(data.dwFileAttributes==FILE_ATTRIBUTE_DIRECTORY){
                    cout<<"filename:"<<data.cFileName<<";"<<endl;
                    if(CString(data.cFileName).Find("..")<0){
                        cout<<"folder:"<<data.cFileName<<";"<<endl;
                    }
                }else{
                    //this->checkMakePath(tempLocal);
                    tempFtp.Append(data.cFileName);
                    tempLocal.Append(data.cFileName);
                    cout<<"file:"<<tempLocal<<endl;
                    //::FtpGetFile(hConnect,tempFtp,tempLocal,false,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_BINARY,0);
                }*/
            }
        }
Taurus
  • 73
  • 6
  • Are you asking why some FTP servers will return the `.` and `..` directory entries in a directory listing, but other servers might not? – sarnold May 02 '12 at 07:36
  • I think that's just what i mean.So it really just matters with different servers/settings? – Taurus May 02 '12 at 07:43
  • 1
    Yeah; there is no standard of the format FTP servers should respond to directory listing requests, and some may or may not show all directories or all files... – sarnold May 02 '12 at 07:45

0 Answers0