Putting into Recycle Bin in VB 2005?

J

johnb41

I searched and found a way (via API) t0 add a deleted file to the
recycle bin. (Thanks Ken Tucker! :))

But I was wondering if VB.NET 2005 (framework 2.0) has a non-api
solution.

(Note: i think it's crazy that you have to manually add code to add a
file to the recycle bin. You'd think the opposite would be true. i.e.
deleting a file and skipping the recycle bin would need special code.)

Thanks!
John
 
J

Joseph Bittman MVP MCSD

January 3, 2005

Never thought about that! Good idea!

What I would expect for something like that (if it is not already there) is:

Public Class File -- From IO

Shared Sub Delete(byval FilePath as string) - Also sends to recycle bin

Shared Overloads Sub Delete(byval FilePath as string, byval SendToRecycleBin
as boolean) - Doesn't send if 2nd para = False


--

Joseph Bittman
Microsoft Certified Solution Developer
Microsoft Most Valuable Professional -- DPM

Blog/Web Site: http://71.39.42.23/
 
M

Mitchell S. Honnert

Check out this method...

My.Computer.FileSystem.DeleteFile

Is has a parameter for optional sending to the Recycle Bin.

Like Joseph, I would have expected this to be in the IO namespace
(specifically System.IO.File.Delete) for for some unfathamable reason, MS
chose to hide this in the My namespace. I can see where MS would want to
aggregate a bunch of commonly-used method from across the entire Framework
into a nice, easy-to-access namespace. So, I personally agree with the
whole My thing. But what I don't get is why they would add functionality
*only* to the My namespace. Fair enough if you want to make it easier on
the people who don't know the Framework, but don't do it in such a way that
it actually makes it harder for people who *do* know the Framework.
OK. I feel better now. :)

- Mitchell S. Honnert
 
J

johnb41

Thanks Joseph and Mitchell! Yes, it doesn't make sense that the My
namespace supports it but IO doesn't. It's an obvious feature that
should have been in IO from day one. Well, at least it's supported in
some fashion. Thanks for the tip!

John
 
G

Guest

hmm thats interesting!
I wonder how MS have implemented it in the My namespace, presumably they
must use an api call if its not in the framework ...

guy
 
M

Mitchell S. Honnert

I wonder how MS have implemented it in the My namespace, presumably they
must use an api call if its not in the framework ...
It's in the Framework; it's just not in the right *place* in the Framework.
Or to be more precise, it's not in the place someone who is experienced with
previous versions of the Framework would expect it to be.

- Mitchell S. Honnert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top