Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

To delete a file from an FTP server, an application can use the FtpDeleteFilefunction. 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_FTPEdit2edit box. The HINTERNEThandle hSecondarywas created by InternetConnectafter establishing an FTP session. DisplayDiris another function that is designed to enumerate the directory.

Copy Code
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