Mandar a la papelera

31/01/2005 - 00:25 por ibon | Informe spam
Hola a todos !!

La cuestión es que tengo una pequeña aplicación que lee ficheros del disco
y, tras hacer X cosas, los eliminar. Me gustaría saber si es posible, en vez
de eliminarlos por completo, mandarlos a la papelera de reciclaje.

El código que uso para eliminar el fichero es el siguiente:
System.IO.File.Delete(file)

Gracias de antemano, IBON

Preguntas similare

Leer las respuestas

#1 Jorge Serrano [MVP VB]
31/01/2005 - 09:27 | Informe spam
Hola ibon,

deberás utilizar la API de Windows para hacer esta tarea;


' DECLARACIONES
<Runtime.InteropServices.DllImport("shell32.dll",
entrypoint:="SHFileOperationA", _
setlasterror:=True, CharSet:=Runtime.InteropServices.CharSet.Auto,
exactspelling:=True, _
CallingConvention:=Runtime.InteropServices.CallingConvention.StdCall)> _
Public Shared Function SHFileOperation(ByRef lpFileOp As SHFILEOPSTRUCT)
As Integer
End Function

Structure SHFILEOPSTRUCT
Dim hwnd As Integer
Dim wFunc As Integer
Dim pFrom As String
Dim pTo As String
Dim fFlags As Short
Dim fAnyOperationsAborted As Integer
Dim hNameMappings As Integer
Dim lpszProgressTitle As String ' only used if FOF_SIMPLEPROGRESS
End Structure

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





' LLAMADA
Dim sh As New SHFILEOPSTRUCT
With sh
.wFunc = FO_DELETE
.pFrom = "c:\zzz.txt"
.fFlags = FOF_ALLOWUNDO
End With
If SHFileOperation(sh) <> 0 Then
MessageBox.Show("Error deleting file")
End If


Espero que te sirva.

Un saludo,

Jorge Serrano Pérez
MVP VB.NET


"ibon" wrote:

Hola a todos !!

La cuestión es que tengo una pequeña aplicación que lee ficheros del disco
y, tras hacer X cosas, los eliminar. Me gustaría saber si es posible, en vez
de eliminarlos por completo, mandarlos a la papelera de reciclaje.

El código que uso para eliminar el fichero es el siguiente:
System.IO.File.Delete(file)

Gracias de antemano, IBON



email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida