FileExists Error

Hi you experts.

I have a file that has ".." in it's name and for that i think FileExists cannot see the file even if it's there.
How can i prevent this? Is there another way to make sure tha a file exists?
Who is Participating?
This worked for me:

      System.IO.FileInfo file = new System.IO.FileInfo("C:/");
File.Exists works as well

using System.IO;

MessageBox.Show(File.Exists("C:\\a..N.txt").ToString() );
Bob LearnedCommented:
What about this--'..\..\test.txt'?  This file would have to exist 2 directories up from the current directory.

I'm not sure about this problem, I've encountered FileExists fails in another scenario. might be related to this prob.

If you have a folder with trailing space char, file.exists fails for anything in that path. Now, you can't make a folder like this ("j2sdk1.4.1_01 " - notice last whitespace) in Winxp anymore, such folder names must have been created in older Windows or non-Win OS. Even winexplorer failes to show properties of any file in such path.

@adktd, let me know if winexporer can show props of you file. if it does, it could be some coding error. if it can't, its an OS bug.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.