views:

1007

answers:

3

Hi,

I need to Move a file to recycle bin in .net 2003

I added microsft.visualbasic.runtime dll from refrence, but i could not able to get filesystem.deletedirectory, So what to do..Can any one help me?

A: 

This might help you. Looks like you need to either add a reference to Microsoft.VisualBasic.dll or use P/Invoke.

Jakob Christensen
+12  A: 

I found this, don't know if it works, but it's worth a shot.

using Microsoft.VisualBasic;

string path = @"c:\myfile.txt";
FileIO.FileSystem.DeleteDirectory(path, FileIO.UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);

EDIT: Wise words from Nifle: Just remember to add a reference to Microsoft.VisualBasic.dll

Marcus L
+1 This does indeed work. I was just going to post the same answer myself.
Nifle
Just remember to add a reference to Microsoft.VisualBasic.dll
Nifle
Good point - will add to answer.
Marcus L
Btw, it uses P/Invoke, as it seems from Reflector
abatishchev
A: 

Have you got a

using Microsoft.VisualBasic.FileIO;

at the top of your page?

ck