By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,640 Members | 2,077 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,640 IT Pros & Developers. It's quick & easy.

DirectoryNotFoundException - Could not find a part of the path "D:\".

P: n/a
Creating a subfolder within my ASP.NET application folder fails with the
above error, but only at my hosting provider. The command:
Directory.CreateDirectory(path)

Path is set to 'D:\appfolder\test2'. ASPNET has full control on the
application folder.

Any ideas why this fails?

- Tom

Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi,

are you sure your provider has D:/ driver on the host server ?

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2

P: n/a
Yes. It is confirmed in the documentation of the provider. And I get it from
the AppDomain.CurrentDomain.BaseDir.

Could it be, that ASPNET need browsing rights on the D drive?

- Tom

"Natty Gur" <na***@dao2com.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

are you sure your provider has D:/ driver on the host server ?

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #3

P: n/a
The following code fails with above error message:
parentpath = AppDomain.CurrentDomain.BaseDirectory + "_Portals/";
s = System.IO.Path.Combine(parentpath,"_test");
System.IO.Directory.CreateDirectory(s);

I've debugged the problem at my hosting provider by creating a test page and
using the Directory and DirectoryInfo classes:

Creating Folder "D:/portalapp/public_html/_Portals/_test" failed:
Could not find a part of the path "D:/".

Current Folder C:\WINNT\system32

Drives: A:\C:\D:\Z:\

Parentfolder D:\portalapp\public_html\_Portals exists
Parentfolder D:\portalapp\public_html exists
Parentfolder D:\portalapp exists
Parentfolder D:\ does not exist.
Rootfolder D:\ does not exist.

If anybody has an idea why ASPNET can see the D:\ drive but doesn't seem to
find it when creating a subdirectory, please let me know.

- Tom

"Natty Gur" <na***@dao2com.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

are you sure your provider has D:/ driver on the host server ?

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #4

P: n/a
Tom hi,

I can't get something. You are writing that D driver doesn't exist
"Parentfolder D:\ does not exist Rootfolder D:\ does not exist" and you
expect .Net to create sub directory there? Maybe d:/ is mapping to
remote storage (NAS, SAN). If so ASP.NET defaults user don't have rights
to access remote resources.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #5

P: n/a
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

"Tom Vogel" <tv**@yahoo.com> wrote in message
news:O2*************@TK2MSFTNGP09.phx.gbl...
The following code fails with above error message:
parentpath = AppDomain.CurrentDomain.BaseDirectory + "_Portals/";
s = System.IO.Path.Combine(parentpath,"_test");
System.IO.Directory.CreateDirectory(s);

I've debugged the problem at my hosting provider by creating a test page and using the Directory and DirectoryInfo classes:

Creating Folder "D:/portalapp/public_html/_Portals/_test" failed:
Could not find a part of the path "D:/".

Current Folder C:\WINNT\system32

Drives: A:\C:\D:\Z:\

Parentfolder D:\portalapp\public_html\_Portals exists
Parentfolder D:\portalapp\public_html exists
Parentfolder D:\portalapp exists
Parentfolder D:\ does not exist.
Rootfolder D:\ does not exist.

If anybody has an idea why ASPNET can see the D:\ drive but doesn't seem to find it when creating a subdirectory, please let me know.

- Tom

"Natty Gur" <na***@dao2com.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

are you sure your provider has D:/ driver on the host server ?

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.