Visual Basic - komo borrar un archivo desde un command

Life is soft - evento anual de software empresarial
 
Vista:

komo borrar un archivo desde un command

Publicado por Energy (48 intervenciones) el 17/05/2002 04:02:40
komo le puedo hacer para ke un command o boton me borre un archivo desde un form???
porfavor espero esa respuesta
ha de ser facil pero no lase :S
grax
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:komo borrar un archivo desde un command

Publicado por jlcastro (114 intervenciones) el 17/05/2002 07:47:56
1.- Borrarlo defenitivamente
Usando Kill "

Kill "C:\fichero a borrar

Borrar un fichero y enviarlo a la papelera de reciclaje:

Crear un formulario y escribir el siguiente código:
Private Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type

Private Declare Function SHFileOperation Lib "shell32.dll" Alias
"SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

Private Const FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40

Public Sub PapeleraDeReciclaje(ByVal Fichero As String)
Dim SHFileOp As SHFILEOPSTRUCT
Dim RetVal As Long
With SHFileOp
.wFunc = FO_DELETE
.pFrom = FileName
.fFlags = FOF_ALLOWUNDO
End With
RetVal = SHFileOperation(SHFileOp)
End Sub

Private Sub Form_Load()
Recycle "c:\a.txt"
End Sub
El programa preguntará si deseamos o no eliminar el fichero y enviarlo a la papelera de reciclaje. El parámetro .fFlags nos permitirá recuperar el fichero de la papelera si lo deseamos. Si eliminamos esta línea, el fichero no podrá ser recuperado.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar