I'm using LAME encoder to encode an audio file from .wav
to .mp3
, to achieve this, I create a procces that encodes the audio file and tries to delete the old .wav
file.
//command = start the lame exe
//params = lame encode params
if (CreateProcess(command, params, NULL, NULL, false,CREATE_NEW_CONSOLE, NULL, NULL, &sInfo, &pInfo)){
WaitForSingleObject(pInfo.hProcess, INFINITE);
CloseHandle(pInfo.hThread);
CloseHandle(pInfo.hProcess);
//Encoding process ended.
remove(filePath);
}
The problem comes when the program tries to delete the file, it's opened by an unknown task, so the deletion becomes impossible.
I need that file to be deleted there.
Is there any way to close all tasks using the file? If not, is it possible to force a delete while the file is being used?