Home > ASP.NET > Deleting file to Recycle Bin using C#

Deleting file to Recycle Bin using C#

At first glance, there is no library/dll in C# that will automagically delete a file to the recycle bin. However if you were to look around, there is a function inside VB which does this.

The good thing about .NET is that everything is just libraries, VB, C# these are just the high level programming languages and you are free to use any function across the board.

 

So in order to delete a file to recycle bin inside a c# app, first add a reference to Microsoft.VisualBasic

image

 

Then inside your code you just do this

image

 

 

For more details on that function, you can refer to https://msdn.microsoft.com/en-us/library/ms127976%28v=vs.110%29.aspx

Categories: ASP.NET
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: