By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,652 Members | 1,905 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,652 IT Pros & Developers. It's quick & easy.

Can files deleted by System.IO.File.Delete method be restored?

P: n/a
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


Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Raymond Du" <rd**@yahoo.com> schrieb:
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?


They cannot be restored using the recycle bin, but the data maybe can be
restored using certain special software.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2

P: n/a
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

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.