Hey, my code fragment is now this:

File fileName = "E:\\Major Project\\FinalLap\\278d.gz.txt.txt";
int index = fileName.toString().lastIndexOf("\\");
filed = fileName.toString().substring(0, index);

And I hope to just get the file's name "278d.gz.txt.txt" after the last instance of "\\" and assign it to variable "filed".
Can anyone tell me what am I doing wrong? Cause I'm still getting the full path.

Thanks a lot!

check out the params for substring - you select a substring starting at 0 ending at the last \, but you want one starting at the last \ and extending to the end of the string.

filed = fileName.toString().substring(index+1);

got it! thanks.