Alright so I am trying to detect if a directory named "C:\\A&B" exists and low and behold, Directory.Exists will not work. Why you ask Well, when I step through the code it changes the string's value to "C:\\AB". Apparently Microsoft thought it would be a good idea to just remove any abnormal characters. To work around this, I just get the directories last modified time and if it exists it returns something otherwise it throws and exception. How do I just discard this IOException

Directory.Exists SUCKS!
watch is
to discard the IOException, use a try catch block:
try
{
//your stuff
}
catch (IOException ex)
{
//handle it
}
however I am unable to reproduce the problem, I've been able to do it just fine. Something wrong in your code somewhere :-)
Nitesh Ambastha
try {
//something that throws IOException
} catch (IOException ex) {
}
GL,
Jasmine
BradyGuy
albidochon
The line:
Console.WriteLine(System.IO.Directory.Exists("
C:\\A&B"));works perfectly fine for me. (I've tried it both with & without the directory existing)
Where is it removing the "&" (Note that in many places in the Windows UI an "&" means "underscore the next character to indicated that it's a hotkey", and you have to write "C:\\A&&B" to get what you want.)