FileExists Error

Posted on 2006-03-29
Medium Priority
Last Modified: 2010-04-16
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?
Question by:adktd
LVL 34

Accepted Solution

flavo earned 100 total points
ID: 16320686
This worked for me:

      System.IO.FileInfo file = new System.IO.FileInfo("C:/test..it.txt");
LVL 10

Expert Comment

ID: 16323767
File.Exists works as well

using System.IO;

MessageBox.Show(File.Exists("C:\\a..N.txt").ToString() );
LVL 96

Expert Comment

by:Bob Learned
ID: 16324480
What about this--'..\..\test.txt'?  This file would have to exist 2 directories up from the current directory.


Expert Comment

ID: 16324704
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.

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Integration Management Part 2
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month15 days, 18 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question