Compartilhar via


Deleting Files from an FTP Server

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

To delete a file from an FTP server, an application can use the FtpDeleteFile function. The calling application must have the necessary privileges to delete a file from the FTP server.

The following example shows how to delete the file indicated by the IDC_FTPEdit2 edit box. The HINTERNET handle hSecondary was created by InternetConnect after establishing an FTP session. DisplayDir is another function that is designed to enumerate the directory.

int WINAPI DeleteFile(HWND hX)
{
    char strInFile[80];
    strInFile[0] = 0;
    GetDlgItemText(hX,IDC_FTPEdit2,strInFile,80);

    if (strlen(strInFile)==0)
    {
        MessageBox(hX,"File Name Must Be Specified.","Remove Dir",MB_OK);
        return 0;
    }
    else
    {
        if(!FtpDeleteFile(hSecondary,strInFile))
        {
            ErrorOut(hX,GetLastError(),"Remove Dir");
            return 0;
        }
        else
        {
            MessageBox(hX,"File Deleted","Remove Dir",MB_OK);
            return DisplayDir(hX,INTERNET_FLAG_RELOAD);
        }
    }
}//end

See Also

Concepts

FTP Sessions

Other Resources

WinInet Application Development