Eliminar Archivo de un ftp desde vs2005
Publicado por Mario (22 intervenciones) el 18/04/2011 17:45:35
HOLA AMIGOS, ESPERO PUEDAN AYUDARME ESTOY TRABAJANDO CON VISUAL STUDIO 2005 Y NO CONSIGO ELIMINAR UN ARCHIVO DEL FTP, ENCONTRE UN EJEMPLO EN VB PERO NO ME FUCIONA Y UNO DE LOS PROBLEMAS ES EL COMANDO "INET" EL CUAL NO LO RECONOCE EL .NET:
http://www.recursosvisualbasic.com.ar/htm/trucos-codigofuente-visual-basic/260-inet-ftp-eliminar-archivo.htm
Private Sub cmd_Eliminar_Click()
'le envía los datos para eliminar el archivo, si _
retorna True es por que no hubo Error
If Eliminar_Ftp(txt_Servidor, _
txt_Usuario, _
txt_Password, _
Txt_Path, _
txt_Archivo) Then
MsgBox " Archivo eliminado", vbInformation
End If
End Sub
'Recibe el nombre del Host, el usuario y contraseña _
el path donde ubicarse y el archivo a eliminar
Function Eliminar_Ftp(Servidor_Ftp As String, _
Usuario As String, _
Password As String, _
Path, _
Archivo As String) As Boolean
On Error GoTo err_Ftp
If LCase(Left(Servidor_Ftp, 6)) <> "ftp://" Then
Servidor_Ftp = "ftp://" & Servidor_Ftp
End If
'Establece al control Inet el usuario, password y nombre del Host FTP
inet_FTP.URL = Servidor_Ftp
inet_FTP.UserName = Usuario
inet_FTP.Password = Password
'Cambia al path indicado que tiene el archivo a eliminar
Call inet_FTP.Execute(, "CD " & Path)
'Esto Indica si el control está ocupado actualmente
Do While inet_FTP.StillExecuting()
DoEvents
Loop
'Esta línea elimina el fichero
Call inet_FTP.Execute(, "DELETE " & Archivo)
Do While inet_FTP.StillExecuting()
DoEvents
Loop
'Eliminó correctamente
Eliminar_Ftp = True
Exit Function
'Error
err_Ftp:
Eliminar_Ftp = False
MsgBox Err.Description, vbCritical
End Function
Private Sub Form_Load()
cmd_Eliminar.Caption = " Eliminar "
End Sub
ESPERO PUEDAN AYUDAR, MUCHAS GRACIAS DESDE YA...¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
http://www.recursosvisualbasic.com.ar/htm/trucos-codigofuente-visual-basic/260-inet-ftp-eliminar-archivo.htm
Private Sub cmd_Eliminar_Click()
'le envía los datos para eliminar el archivo, si _
retorna True es por que no hubo Error
If Eliminar_Ftp(txt_Servidor, _
txt_Usuario, _
txt_Password, _
Txt_Path, _
txt_Archivo) Then
MsgBox " Archivo eliminado", vbInformation
End If
End Sub
'Recibe el nombre del Host, el usuario y contraseña _
el path donde ubicarse y el archivo a eliminar
Function Eliminar_Ftp(Servidor_Ftp As String, _
Usuario As String, _
Password As String, _
Path, _
Archivo As String) As Boolean
On Error GoTo err_Ftp
If LCase(Left(Servidor_Ftp, 6)) <> "ftp://" Then
Servidor_Ftp = "ftp://" & Servidor_Ftp
End If
'Establece al control Inet el usuario, password y nombre del Host FTP
inet_FTP.URL = Servidor_Ftp
inet_FTP.UserName = Usuario
inet_FTP.Password = Password
'Cambia al path indicado que tiene el archivo a eliminar
Call inet_FTP.Execute(, "CD " & Path)
'Esto Indica si el control está ocupado actualmente
Do While inet_FTP.StillExecuting()
DoEvents
Loop
'Esta línea elimina el fichero
Call inet_FTP.Execute(, "DELETE " & Archivo)
Do While inet_FTP.StillExecuting()
DoEvents
Loop
'Eliminó correctamente
Eliminar_Ftp = True
Exit Function
'Error
err_Ftp:
Eliminar_Ftp = False
MsgBox Err.Description, vbCritical
End Function
Private Sub Form_Load()
cmd_Eliminar.Caption = " Eliminar "
End Sub
ESPERO PUEDAN AYUDAR, MUCHAS GRACIAS DESDE YA...¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
Valora esta pregunta


0