You are 100% correct. OP is trying to work with the file name as a String instead of creating an instance of the File class.