This is a relatively known .NET bug or "feature"...
Both Directory.CreateDirectory(path) and
DirectoryInfo.CreateSubdirectory(path) require user to have Read access to
the drive's root directory (i.e. <Drive>:\).
Many ASP.NET hosting providers (especially those running Windows 2003
Server) will not allow user running ASP.NET working process read access to
the root folder, so CreateDirectory will always fail. You can not blame
hosting providers - they do right thing, securing shared environment from
users with malicious intents.
The only workaround I have found is to replace call to
Directory.CreateDirectory() with call to unmanaged code, like msvcrt's
_mkdir(char*):
[DllImport("msvcrt.dll", SetLastError=true)]
static extern int _mkdir(string path);
....
//replace call to Directory.CreateDirectory with:
_mkdir(newDirectory);
....
This will work only if your code is granted "Allow Calls to Unmanaged Code"
permission but most hosting environments allow that.
You can find more details in my recent Blog entry at
http://hatka.net/wlogdev/archive/2004/08/29/178.aspx
Dmitry Kulakovsky