File.Exists is not remotely working!!!

Every single time i use File.Exists it simply REFUSES to be even 0.0000001% accurate…ok overstatement yes but my point is it ALWAYS returns false, with the simple exception of the time where i use a file path derived from a DirectoryInfo call. this is extremely frustrating due to the fact that yes, im using the absolute path, yes i even tried path.combine…but nothing…nothing works. this is so utterly aggrivating

my current alternative is to have a sort of “manual” file.exists in the context of the script by which i would pull all files via DirectoryInfo, and compare them to the file im looking for untill it tells me it does or doesn’t exist.

this is very very frustrating and its making my save system significantly more complex then it needs to be.
thank you so much to anybody who can help point me in the right direction towards using this CLEARLY broken function.

and for posterity’s sake:

print(File.Exists(Path.Combine(Application.dataPath ,String.Format("/../saves/{0}{1}.txt",cont.instance.Savedata[0].Name,count))));

^this returns false even tho im literally looking on my screen right now at the file. that was saved a min ago using the EXACT same path information…yet it does not “exist”…

when i print just the path without the “file.exists” portion, it comes up VERBATIM to what i see on my screen with the folder open. and no, File.OpenRead doesn’t recognize it either, again however returning the path verbatim.

my appolagies for the “flaming” but this issue has cropped up several times durring this phase of development and its giving me the biggest frustration headache ever lol. i see absolutely no reason this shouldn’t work…and yet it doesn’t

if I’M doing something wrong…just let me down easy…XD again thanks for any and all help!

Did you try to use Path.GetFullPath to eliminate the “…”? If I remember correctly, some operations don’t like “…”.

Here are a few things you could try:

Debug.Log(Path.Combine(Application.dataPath ,String.Format("/../saves/{0}{1}.txt",cont.instance.Savedata[0].Name,count)));

Verify the logged path is exactly what you expect

You said you just wrote to this file. Make sure the file handle is closed. You should be able to open the file in another program if this is the case.

Check the permissions on the file and directory. I’m not sure how this could happen but maybe Unity doesn’t have Read or List folder contents access to this directory?

THANK YOU!!! this is perfect, thank you so much for your quick response!! you’ve really helped me out!

thanks so much for the response! i should have worded that better lol. 99% of the time when i save a file , i immedietly stop the game to clear its references from memory so they don’t interfer with tests (like file.exists)

i didn’t test this out but if this problem comes back up this is the first thing i’ll try! thanks again!