Author Topic: Media folder remains locked after BASS_StreamFree  (Read 309 times)


  • Posts: 58
Tried this on precompiled basstest.exe, on Windows XP SP2.

Create a folder, put one wav or mp3 file into it.

Using basstest.exe,
Add the wav or mp3 file from the folder to the playlist.
Play it.
Remove it.
Don't quit basstest.exe yet.

Now using explorer.exe:
Delete the file just played.
Try to delete its folder. Fails because the folder remains locked by basstest.exe.

Now using the still running basstest.exe,
Add some mp3 or wav from a different folder to the playlist.
Play it.

Now using explorer.exe:
Once again try to delete the previous folder, the one whose deletion failed. This time it is successfully deleted !!

Am I missing something ?
I don't expect this to be the intentional behaviour.

Also, I noticed that Bass locks the file(s) currently playing. This can be useful in certain circumstances, and annoying in others. VLC does the same as Bass, while Media Home Player and WMP don't seem to lock the files, at least the 2-3 MB files I tried. May it be that they buffer the entire file ? Because with them I can delete the files and the playing continues.

@ Ian:
For me, the best behaviour would be to be able to choose to lock or not to lock, and if not locked, then for Bass to fail gently if the file is deleted / moved while playing. I guess implementing this could be tricky. Specially the error / stall notification. So I'm not asking for it, just suggesting.

Thanks in advance!

Ian @ un4seen

  • Administrator
  • Posts: 21363
Re: Media folder remains locked after BASS_StreamFree
« Reply #1 on: 27 Nov '17 - 16:21 »
I think what's happening there is that the file selector (GetOpenFileName) is setting the process's current directory to the one the selected file is in, and Windows won't let you delete the directory because of that. You could try adding the OFN_NOCHANGEDIR flag to the OPENFILENAME (ofn) structure.


  • Posts: 58
Re: Media folder remains locked after BASS_StreamFree
« Reply #2 on: 27 Nov '17 - 23:50 »
Thanks, Ian ! That did the trick.

It was a bit misleading that in the VB6 IDE this problem didn't show, but only in the compiled exe. That's why I tried your precompiled exe from the bin folder.

After trying your suggested solution
    DLG.flags = cdlOFNNoChangeDir
I also tried reseting the current directory after returning from DLG.ShowOpen
    ChDrive App.Path
    ChDir App.Path
Both solutions worked.

Now I must dig into my application to find where the current directory gets changed...