473,387 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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
2 3894
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Raj | last post by:
Hi all, Can anyone help me with a script which would delete files or move them to a different folder at some scheduled time..! Please.....!!! Thanks in advance...
11
by: Viviana Vc | last post by:
Hi all, I would like to delete from a directory all the files that match: bar*.* I know that I could do for instance: system("del bar*.*"), but this will bring up the command prompt window and...
5
by: Rosa | last post by:
Hi, I'm trying to clear the TIF on Windows XP programmatically with the below code. This code works fine on any folder but the TIF. For some reason the atEnd() statements always defaults to true...
1
by: Frank Lopez | last post by:
In .NET and C#, is there anyway to create a hook for a specific directory or file where my C# .NET software can monitor which static web files are requested by the browser? What I am doing is...
2
by: Stuart Norris | last post by:
Dear Readers, I am developing an application that stores "messages" in array list and writes new entries to a disk file at the end. This file is used incase the user choses to restart the...
3
by: richardkreidl | last post by:
I have the following module that I delete old files based on how old they are: Sub Main() Dim First_Date As String = Date.Today.AddDays(-7) Dim Archive_Files() As String =...
7
by: elgiei | last post by:
Good morning at all, i have to implement a server,that every n-seconds (eg. 10sec) sends to other clients,which files and directory has been deleted or modified. i build a n-tree, for each...
5
by: techusky | last post by:
I made a script that successfully creates a .zip file of all the files in a directory on my web server, but now what I haven't figured out how to do is how to have it automatically deleted when the...
12
Nepomuk
by: Nepomuk | last post by:
Hi! I want to have my program delete some folders including all contents. For that, I wrote this method: private static void delete(String source) { File tmp = new File(source);...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.