you're continuing to run the loop after you've found it, which means you'll come into your 'else' block again. and there you overwrite the value you have stored.
I think, a better way would be to run your loop, when you've found your desired index, don't store it in a value, just immediately return it. and after the loop, just put return -1, this way, if your index is not found, you'll still return -1.
You loop through all the files in drive. When you hit the right one you set value = i, which is the index you want. But then you continue through the rest of the array, and set value = -1 overwriting the value you wanted (unless the one you wanted happened to be the last file in the array). As soon as you hit the required file you should return immediately, as in
if(drive[i]!=null ....) return i;
then after the loop, if you get that far you konw you didn't find the file so you can
Not quite right. What happens if the correct file is in drive? - it's not in drive so you immediately return -1 and that's it. You get the error message because Java sees that if you complete the loop you will go from line 9 to line 10 and exit the method without returning anything. You know that that's not possible with your code, but Java doesn't.
Time to go back and read the previous posts with the same care that they were written with. You just had two independent posts that both said "after the loop ... return -1;"
Lines 2 and 4 are redundant - you never use the value of int indexOfFile.
The structure looks OK now, so you should use print statements to check the data values. eg instead of line 4 try System.out.println(drive.getName()); so you can see what's actually happening in your loop.
also, make sure you take everything in account: case sensitivity and all .. do as JamesCherrill suggested, and also print the value your testing against: filename, that should give you everything you need.