Correct Way: Check Soundfile exist

 
hi,

I have a small question for coders:

In MT4: What is the correct way to check if a particular sound file exist.
PlaySound(SoundFileName);

If the SoundFile does not exist it seems I get no error message - it's just skipped.

Thanks a lot.
 
M_j:

In MT4: What is the correct way to check if a particular sound file exist.
PlaySound(SoundFileName);

If the SoundFile does not exist it seems I get no error message - it's just skipped.

There isn't any.

You could check GetLastError() Before to clear and then after. don't know if it sets.

You could shell a cmd /c DIR /b «terminalDIR»\sounds\«filename» >«terminalDIR»\files\listing.txt and then read the resulting file to see if it exists.

Or just make the name an external, letting the user specify and responsible.

 
 
The 720 is nice. Since the OP doesn't want to read the file but only determine its existence, the directory functions in Grouped File Operations - https://www.mql5.com/en/articles/1543 Might be better
Reason: