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?
LVL 1
adktdAsked:
Who is Participating?
 
flavoCommented:
This worked for me:

      System.IO.FileInfo file = new System.IO.FileInfo("C:/test..it.txt");
      MessageBox.Show(this,file.Exists.ToString());
0
 
dkloeckCommented:
File.Exists works as well

using System.IO;

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

Bob
0
 
RoninTheCommented:
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.
0
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.