You need to check whether RandomFileNum is inside the range of your ListOfFolder before accessing it.
Also you should not use Exception.Create to pass it along to ShowException, because the exception object will not be freed in that case. Better use MessageDlg or ShowMessage with only the string or use raise Exception.Create('...'); instead of ShowException(...) (you don't need the Terminate then either).