Results 1 to 11 of 11

Thread: Can't Delete A File After Opened In Windows Media Player...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Can't Delete A File After Opened In Windows Media Player...

    I have a file (.mp3) opened with the Windows Media Player control. I stop the file from being played and attempt to Kill everything in the directory the file is in. It will clear the directory with the exception of that file. I've even set the Media Player .URL to "" and tried. The file stays in the folder. If I double-click on it within the actual folder (windows explorer), it will open up Winamp to play it, but will not play. It still holds the same filesize, as if it truly existed. I can skip down the code to continue the program and it still stays. Only when I stop the project from running does the file disappear. What the hell?

  2. #2
    Hyperactive Member
    Join Date
    Oct 2013
    Posts
    389

    Re: Can't Delete A File After Opened In Windows Media Player...

    What pops to mind is that you probably did not clean up as you should have.
    do me a favor though, compile and see if the Executable behave the same. maybe it's just the IDE hanging it.
    also refresh folder (F5) after file was supposed to be "deleted" see if it stays.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: Can't Delete A File After Opened In Windows Media Player...

    Okay, now it's not even allowing me to delete the file in the folder after I stop the project. I can delete it in the folder, but then refresh it (F5) and it will still be there. It's only after I exit Visual Basic ENTIRELY does it actually delete it on it's own without me doing ANYthing. This is seriously stupid. I've started the song, stopped the song, changed the URL of the player... nothing that allows me to delete the file. I've never seen this before and seems really ridiculous the the media player can have such a hold on a file.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: Can't Delete A File After Opened In Windows Media Player...

    I've saved it as an executable... it does the same thing until I close the app.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: Can't Delete A File After Opened In Windows Media Player...

    Do this:

    Create a new folder and put an .mp3 in it. Open a new VB6 project. Add the Windows Media Player to it. Set it's URL to the .mp3. Have it play the .mp3. Have it stop the .mp3. Even change the .URL to nothing. Keep the project running and see if you can delete the .mp3 from the folder, making sure to refresh the folder to see if it's truly gone. If not, stop the project and watch it disappear. It's the dumbest thing.

  6. #6
    Hyperactive Member
    Join Date
    Oct 2013
    Posts
    389

    Re: Can't Delete A File After Opened In Windows Media Player...

    I just did and i can delete the file, no problem there. make sure the MP3 is not Read-Only and that you set the URL to a false path (not "" but try some path that doesnt exist like "C:\bla.mp3" or something, if you set to vbNullstring (aka "") it doesn't actually invoke the change of URL.
    Also, WindowsMediaPlayer.Close may be required prior to deleting the file.
    Last edited by stum; Apr 28th, 2015 at 02:07 PM.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: Can't Delete A File After Opened In Windows Media Player...

    Okay. I've set the .URL to something that doesn't exist and it's still doing it. Only now, it takes about 5 seconds to delete it. I can let the program sit there for five seconds after it supposedly kills everything in the folder and watch it disappear on it's own. It will delete everything else in a blink, except for the file I just played with the WMP control.
    Also, did you use the Kill command to remove everything in the folder? Because that's what I'm doing and it's obviously not "killing" everything.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: Can't Delete A File After Opened In Windows Media Player...

    I started a new project and attempted the same thing, this time creating an array of the WMP control and then unloading the array before using the Kill command to delete everything in the directory. Same outcome. Only wen I exit Visual Basic does it delete itself.

  9. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Can't Delete A File After Opened In Windows Media Player...

    Are you using Dir$() in your routines? If so, consider calling this before that routine exits: Dir$("")
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    190

    Re: Can't Delete A File After Opened In Windows Media Player...

    Not using Dir$()

  11. #11
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Can't Delete A File After Opened In Windows Media Player...

    Does anything in this off-site link apply? Just guessing at this point
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Tags for this Thread

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