Recycle Bin in asp.net application

Posted by Alok under ASP.NET on 5/18/2011 | Points: 10 | Views : 1929 | Status : [Member] | Replies : 4
I have to create a recycle bin in asp.net Application.
Through this recycle bin how can i recover the deleted items.
should i have to write code to insert data in database again if i chose restor or there is any other methods????
Plz reply ..
Thanks

Thanks & Regards,
Alokssm



Responses

Posted by: Susanthampy on: 5/18/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

http://stackoverflow.com/questions/6025311/how-to-restore-files-from-recycle-bin

try this..............



Regards,
Susan

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Alok on: 5/18/2011 [Member] Starter | Points: 25

Up
0
Down
Actually i have to delete items from gridview using checkbox selection..
the checked items will be deleted...the deleted items will be saved to recycle bin and when we chose restore..
the data should again show in gridview

Thanks & Regards,
Alokssm

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 5/18/2011 [Member] Starter | Points: 25

Up
0
Down
Hi
Just add a column(bit field wil deafult value 0) to the table from which you are showing data in the gridview.
In case of deletion from main gridview set it as 1, and in the gridview show data where this column value is 0.

On restore just set them as 0.

Thanks,
Debata


Alok, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hemanthlaxmi on: 5/18/2011 [Member] Starter | Points: 25

Up
0
Down
This link can help you
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/05f1476f-a101-4766-847b-0bdf4f6ad397
using System;

using System.Collections;
using System.Windows.Forms;
using System.IO;
using Shell32; //Reference Microsoft Shell Controls And Automation on the COM tab.
using System.Runtime.InteropServices;
using Microsoft.VisualBasic.FileIO;
namespace RecyclerCS
{
public partial class Form1 : Form
{
public Form1() {
InitializeComponent();
}
private Shell Shl;
private const long ssfBITBUCKET = 10;
private const int recycleNAME = 0;
private const int recyclePATH = 1;

private void button1_Click(object sender, System.EventArgs e) {
string S = "This is text in the file to be restored from the Recycle Bin.";
string FileName = "C:\\Temp\\Text.txt";
File.WriteAllText(FileName, S);
Delete(FileName);
MessageBox.Show(FileName + " has been moved to the Recycle Bin.");
if (Restore(FileName))
MessageBox.Show(FileName + " has been restored");
else
MessageBox.Show("Error");
Marshal.FinalReleaseComObject(Shl);
}
private void Delete(string Item) {
FileSystem.DeleteFile(Item, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
//Gives the most control of dialogs.
}
private bool Restore(string Item) {
Shl = new Shell();
Folder Recycler = Shl.NameSpace(10);
for (int i = 0; i < Recycler.Items().Count; i++) {
FolderItem FI = Recycler.Items().Item(i);
string FileName = Recycler.GetDetailsOf(FI, 0);
if (Path.GetExtension(FileName) == "") FileName += Path.GetExtension(FI.Path);
//Necessary for systems with hidden file extensions.
string FilePath = Recycler.GetDetailsOf(FI, 1);
if (Item == Path.Combine(FilePath, FileName)) {
DoVerb(FI, "ESTORE");
return true;
}
}
return false;
}
private bool DoVerb(FolderItem Item, string Verb) {
foreach (FolderItemVerb FIVerb in Item.Verbs()) {
if (FIVerb.Name.ToUpper().Contains(Verb.ToUpper())) {
FIVerb.DoIt();
return true;
}
}
return false;
}
}
}


If this helps you .
Please "Mark as Answer"

Alok, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response