Hi,
You can use the SHFileOperation API delete a file to recycle bin.
The api declare
<DllImport("shell32.dll", entrypoint:="SHFileOperationA", _
setlasterror:=True, CharSet:=CharSet.Auto, exactspelling:=True, _
CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function SHFileOperation(ByRef lpFileOp As SHFILEOPSTRUCT) As
Integer
End Function
The structure
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
The constants
Private Const FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40
And finally the same code.
Dim sh As New SHFILEOPSTRUCT
With sh
.wFunc = FO_DELETE
.pFrom = FileName
.fFlags = FOF_ALLOWUNDO
End With
If SHFileOperation(sh) <> 0 Then
MessageBox.Show("Error deleting file")
End If
Ken
--------------------------
"Raymond Du" <rd**@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,
I am working on a VB.Net window application, the application use
System.IO.File.Delete method to delete files, can those deleted files be
restored?
TIA