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 UnauthorizedAccessException
is thrown and the directory is not created.
Sub Main()
Dim path = "C:Windowszzzz"
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
When I run this same bit of code from my production solution, the IO.Directory.CreateDirectory()
method is not throwing an exception, IO.Directory.Exists()
returns True, and the directory does not actually get created on disk.
Are there any project/solution settings that would make the behavior of IO.Directory.CreateDirectory() vary like this?
Note: I am not running Visual Studio as an administrator in either case.
EDIT: The production application is running on the same box as the test application.
EDIT #2: 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:UsersmyUserAppDataLocalVirtualStoreWindows where my created directories were sitting.
The only outstanding question is - why does the production application virtualize while the test console application throws an exception??
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.
Thanks everyone!
See Question&Answers more detail:os