1
Reply

File.Exists and Virtual path

John Griffiths

John Griffiths

14 years ago
10.1k

Sorry for the dumb question, but I'm trying to use File.Exists to check if a file exists in a Virtual Folder '~/XML/Test.xml/', but no matter what ever I try the file isn't detected. I've tested the basic C# code to test the file in @"C:\test.xml" and this works fine. Is there a better solution other than File.Exists that might work?

 

Example Code:

 

using System.IO;

 

string path = "~/XML/Test.xml";

if (File.Exists(path))

{

textBox1.Text = "File does exist";

}

else

{

textBox1.Text = "File does not exist";

}


Answers (1)