Compartir a través de


Navigating Directories (Windows CE 5.0)

Send Feedback

The Windows Internet Services (WinInet) functions FtpGetCurrentDirectory and FtpSetCurrentDirectory handle directory navigation.

FtpGetCurrentDirectory returns the application's current directory on the FTP server. The directory path from the root directory on the FTP server is included.

FtpSetCurrentDirectory changes the working directory on the server. The directory information passed to FtpSetCurrentDirectory can be either a partially or fully qualified path name relative to the current directory. For example, if the application is currently in the directory public\info and the path is ftp/example, FtpSetCurrentDirectory changes the current directory to public\info\ftp\example.

The following example shows how to use the FTP session handle hSecondary, which is returned by InternetConnect. The new directory name is stored in the IDC_FTPEdit2 edit box. Before the actual change is made, the function retrieves the current directory and stores it in the same edit box. DisplayDir is another function that is designed to enumerate the directory.

int WINAPI ChangeDir(HWND hX)
{
    DWORD testsz = 320;
    LPSTR lpszUrlBuffer;            // Buffer to hold the URL
    LPSTR lpszDirList;

    lpszUrlBuffer = new char[testsz];
    if(lpszUrlBuffer)
    {
       *lpszUrlBuffer=0;
    }
    GetDlgItemText(hX,IDC_FTPEdit2,(LPSTR)lpszUrlBuffer,testsz);
    lpszDirList = new char[testsz];
    if (!FtpGetCurrentDirectory(hSecondary,(LPSTR)lpszDirList,&testsz))
    {
        ErrorOut(hX,GetLastError(),"Change Dir");
    }
    else
        SetDlgItemText(hX,IDC_FTPEdit2,(LPSTR)lpszDirList);

    delete(lpszDirList);

    if (!(FtpSetCurrentDirectory(hSecondary,lpszUrlBuffer)))
    {
        ErrorOut(hX,GetLastError(),"InternetConnect");
        delete(lpszUrlBuffer);
        SetDlgItemText(hX,IDC_FTPEdit2,(LPSTR)lpszUrlBuffer);
        DisplayDir(hX,INTERNET_FLAG_RELOAD);
        return 0;
    }
    else
    {
        delete(lpszUrlBuffer);
        return DisplayDir(hX,0);
    }
}

See Also

FTP Sessions

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.