I am having a problem with a piece of code for a web app and hoping you guys can help. What I am needing to do is see if a certain directory exists based on what has been entered into a text box (www.example.com/textinbox).
I have this code:
string directoryString = Server.MapPath(".") + @"\" + directoryname.Text;
if (Directory.Exists (directoryString))
{
Do this stuff.
}
else
{
Do other stuff.
}
However for some reason the first one ALWAYS passes, even if the full path does not exist.
Two questions:
1) Why is this happening?
2) Is there a better way to test to see if a directory exists?
Thanks all!
Chris