title: Why is IO.Directory.CreateDirectory succeeding when it shouldn't?
body: <p>I'm running Visual Studio 2008 on a Vista Ultimate box.  When I create a brand new console application and run the following code via the debugger, I get an expected result -- an <code>UnauthorizedAccessException</code> is thrown and the directory is not created.  </p>
  
  <pre><code>Sub Main()
      Dim path = "C:\Windows\zzzz"
      Try
          IO.Directory.CreateDirectory(path)
      Catch ex As Exception
          Console.WriteLine(ex.Message)
      End Try
      Console.WriteLine(IO.Directory.Exists(path).ToString)
      Console.ReadLine()
  End Sub
  </code></pre>
  
  <p>When I run this same bit of code from my production solution, the <code>IO.Directory.CreateDirectory()</code> method is <em>not</em> throwing an exception, <code>IO.Directory.Exists()</code> returns True, <strong>and the directory does not actually get created on disk.</strong></p>
  
  <p>Are there any project/solution settings that would make the behavior of IO.Directory.CreateDirectory() vary like this?</p>
  
  <p><strong>Note:</strong> I am <em>not</em> running Visual Studio as an administrator in either case.</p>
  
  <p><strong>EDIT:</strong> The production application is running on the same box as the test application.</p>
  
  <p><strong>EDIT #2:</strong> The production application is using virtualization.  I clicked on My Computer, navigated to C:\Windows, and clicked on "Compatibility Files" on the explorer toolbar and it brought me to C:\Users\myUser\AppData\Local\VirtualStore\Windows where my created directories were sitting.  </p>
  
  <p>The only outstanding question is - why does the production application virtualize while the test console application throws an exception?? </p>
  
  <p><strong>Answer: the console application, by default, was created with an app.manifest.  The production application--which is a WPF application--did not have an app.manifest.  Apparently Vista will use virtualization if there is no app.manifest present for the execuable.</strong></p>
  
  <p>Thanks everyone!</p>