Results 1 to 9 of 9

Thread: Moving a file to the recycle bin

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    15

    Moving a file to the recycle bin

    I am writing a program to manage some of my files. I already KNOW when I want to send a file to the recycle bin, so I don't need the system to prompt me each time. How do I tell him to BACK OFF, and just DO IT?

    Here is my code:

    Sub RecycleBinFile(ByVal strFilename As String)
    My.Computer.FileSystem.DeleteFile(strFilename, FileIO.UIOption.AllDialogs, FileIO.RecycleOption.SendToRecycleBin, FileIO.UICancelOption.DoNothing)
    End Sub


    Some of my research has pointed me to FileIO.UIOption.AllDialogs, but I think they're guessing, because I am at a dead end.

    Thanks in advance.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Moving a file to the recycle bin

    If you don't want the system to display a confirmation dialogue then logically AllDialogs would not be the appropriate choice. What other options are there for that parameter?

    That said, as you ALWAYS should be doing when you have a question, you should have gone to the documentation first. The documentation for the My.Computer.FileSystem.DeleteFile has this to say:
    This example deletes the file Test.txt.
    Code:
    My.Computer.FileSystem.DeleteFile("C:\test.txt")
    This example deletes the file Test.txt and allows the user to confirm that the file should be deleted.
    Code:
    My.Computer.FileSystem.DeleteFile _
    ("C:\test.txt", FileIO.UIOption.AllDialogs, FileIO.RecycleOption.SendToRecycleBin, FileIO.UICancelOption.ThrowException)
    This example deletes the file Test.txt and sends it to the Recycle Bin.
    Code:
    My.Computer.FileSystem.DeleteFile _
    ("C:\test.txt", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin, FileIO.UICancelOption.ThrowException)
    So, your question was answered in the Help, which is where you should always be looking first for help, as the name suggests. It should have taken about 30 seconds in total. This is how easy it is to find answers if you use the resources at your disposal.
    Last edited by jmcilhinney; Aug 26th, 2010 at 12:03 AM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    15

    Re: Moving a file to the recycle bin

    You know, I appreciate your help, and the first question you asked opened my eyes, but I am sensing a little bit of a condescending tone in your reply, and that is not appreciated. I am a seasoned mainframe programmer, looking to learn VB.Net. I got tripped up by some of the language that Microsoft has chosen to use, which, as always, is vague.

    What do you mean by "The documentation?" I checked all over Google, and believe me, that took far more than 30 seconds.
    Last edited by Microchip1222; Aug 26th, 2010 at 12:08 AM.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Moving a file to the recycle bin

    Google is not documentation. It's a search engine. The documentation is the reference manual, provided by Microsoft, accessible from the Help menu in Visual Studio. If you haven't installed it then you should do so, or you can use the online version. I just Googled my.computer.filesystem.deletefile myself and here is the result:

    http://www.google.com.au/search?q=my...ient=firefox-a

    The very first result is a link to the online MSDN documentation:

    http://msdn.microsoft.com/en-us/libr...8VS.80%29.aspx

    That's the page that I got my previous quote from. I've been using the documentation myself since I was a beginner. I've answered countless questions from others, even on topics with which I have had no prior experience, simply by reading the documentation. If I can do it then there's no reason that those asking the questions can't do it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    15

    Re: Moving a file to the recycle bin

    The first link you provided is broken.

    The second link you provided, the one to the MSDN documentation, pointed me to what I find is typical of Microsoft. There is NOTHING in there that says this option will stop the system from prompting you. It says that the system will track the progress. I don't WANT the progress tracked.

    I find it MUCH easier to solve problems by looking at examples rather than treading through dozens of screens of esoteric verbiage.

    For what it's worth, I am using VB 2008 Express. I don't believe the MSDN documentation was an option.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Moving a file to the recycle bin

    The first link I provided is what I copied directly from the address bar of Firefox. When I click it it takes me straight to the results of that search in Google. If I open this thread in IE and click the link it also takes me to the same results. The link is not broken. I don't have any other browsers installed I can test it on but you could always just go to Google and perform the same search yourself. Here's the URL that I got when I did that in IE:

    http://www.google.com.au/webhp?hl=en...25f3317bd5ad27

    The very same page is at the top of the list.

    I think that you expect a bit too much for Microsoft to detail every possible permutation. You should be able to work some things out for yourself. The second code example explicitly states that it asks the user to confirm the deletion so, by simple deduction, that would suggest that the other two examples do NOT ask the user for confirmation. One example says it prompts and it uses AllDialogs and another example doesn't say it prompts and it uses OnlyErrorDialogs. That's enough for me. If you expect everything to be spelled out then you'll be disappointed because there are just two many specific details. If I asked you what you were wearing, would you say that you were NOT wearing a hat? I doubt it, but I would probably deduce that you were by the fact that you didn't say that you were.

    The MSDN documentation is a separate download from the same page that VB Express is downloaded from, or it's included in the full ISO download.
    I find it MUCH easier to solve problems by looking at examples rather than treading through dozens of screens of esoteric verbiage.
    I'd say that that's on you, not on them. I've been using the MSDN documentation as my primary (but certainly not only) resource from the day I started working in .NET. Like I said, I've often taken less than a minute to answer questions from the documentation that others claim that they've spent hours on Google trying to answer.
    Last edited by jmcilhinney; Aug 26th, 2010 at 01:00 AM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Moving a file to the recycle bin

    In short, everyone should use the documentation as their first source of information when they already know what type and/or method they need to use, and often even when they don't. If you don't want to then you're only making it harder for yourself, as this situation exemplifies.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    15

    Re: Moving a file to the recycle bin

    Your loyalty to Microsoft is flattering, but my first resource is always Google. I save TONS of time that way, and I get actual examples. And nobody has to assume that I know what they MEAN.

    Cheers

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Moving a file to the recycle bin

    Taking this instance:

    1. The documentation has examples.
    2. The documentation is not vague for a seasoned programmer.
    3. Using the documentation would have taken less than a minute to get the answer, while you apparently spent lots of time on Google for no result.
    4. If the documentation hadn't given the answer, less than a minute would have been spent trying before looking elsewhere.

    I've been developing in .NET for about 8 years. I understand more of what is written in the documentation now than I did when I started, but I still looked there first when I started. If you're a seasoned programmer then you should be able to understand as much as I did then, which was after working with C++ for 2 years. Your mind appears to be made up so I'll say no more, except that it's your loss if you insist on ignoring the single biggest .NET development resource available.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width