I am trying to find a way from a c++ program to (remove, release, clear, etc...) the directory path that used to open a file from an external hard drive (flash disks) and cause the flash disk not to be able to eject with the classic error in windows (it is being used by an application)
The problem is that when you open a file by a c++ program and this file is on an external hard drive even if you close the file, it can't eject the external drive until you close the program that opened that file or the path to that external drive.
I tried to use SetCurrentDirectory()
after each use of a file function in windows but it doesn't seem to work properly.
It still needs something to be released by the program so the external disk can be ejected.
Did anyone find a way to do this?
-------------- UDPATE
Michael Walz is correct.
FindClose(); for some cases
CloseHandle(); for other cases
seems to be working fine by now as far as i tested.
Copyright Notice:Content Author:「Vas」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/48769883/eject-flash-disk-is-currently-used-by-the-application-in-windows