C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to delete a directory and send it to recycle bin


Posted Date: 05 Jun 2008    Resource Type: Code Snippets    Category: Active Directory
Author: Payal JainMember Level: Gold    
Rating: Points: 10



This code will help you know how we can send a directory to recycle bin on deletion.
namespace used for this is Microsoft.VisualBasic.MyServices which will be imported to your application using:

using Microsoft.VisualBasic.MyServices;

you may need to add reference to microsoft.visualbasic.dll to your project.



FileSystemProxy FileSystem = new Microsoft.VisualBasic.Devices.Computer().FileSystem;
FileSystem.DeleteDirectory(@"C:\myfolder", Microsoft.VisualBasic.FileIO.UIOption.AllDialogs, Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin);

FileSystem = null;



In the function DeleteDirectory of FileSystem object you need to pass 3 arguments, 1st is the original path of the Directory and second is the Enum which Specifies which dialog boxes to show when copying, deleting, or moving files or directories.
3rd is also an enum which Specifies whether a file should be deleted permanently or placed in the Recycle Bin.if you want to delete it permanently use Microsoft.VisualBasic.FileIO.RecycleOption.DeletePermanently in 3rd argument.





Responses

Author: Kapil Dhawan    17 Jun 2008Member Level: Gold   Points : 2
Hello
Nice piece of code
Thanks for sharing your knowledge with us.
I hope to see more good code from your side
This code is going to help lots of guys.
Ton Thanks to you
Regards,
Kapil



Author: vilas fulzele    30 Jul 2008Member Level: Silver   Points : 1
Hi,
Very good code.
Thank you for sharing your knowledge with us.

Regards,
Vilas


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Delete a directory  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to rename a directory
Previous Resource: Send a File to recycle bin on deletion
Return to Discussion Resource Index
Post New Resource
Category: Active Directory


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use