Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DirectoryNotFoundException - Could not find a part of the path "D:\".

Reply
Thread Tools

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

 
 
Tom Vogel
Guest
Posts: n/a
 
      05-01-2004
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



 
Reply With Quote
 
 
 
 
Natty Gur
Guest
Posts: n/a
 
      05-03-2004
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!
 
Reply With Quote
 
 
 
 
Tom Vogel
Guest
Posts: n/a
 
      05-03-2004
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" <> wrote in message
news:%...
> 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!



 
Reply With Quote
 
Tom Vogel
Guest
Posts: n/a
 
      05-03-2004
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" <> wrote in message
news:%...
> 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!



 
Reply With Quote
 
Natty Gur
Guest
Posts: n/a
 
      05-04-2004
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!
 
Reply With Quote
 
Dmitry Kulakovsky
Guest
Posts: n/a
 
      08-30-2004
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" <> wrote in message
news:O2#...
> 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" <> wrote in message
> news:%...
> > 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!

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Noob question: "Could not find a part of the path" haylow ASP .Net 0 06-15-2004 08:10 AM
Re: Error: Could not find a part of the path Phil Winstanley [Microsoft MVP ASP.NET] ASP .Net 0 05-21-2004 09:35 AM
Error: Could not find a part of the path jessica ASP .Net 0 05-20-2004 04:16 AM
Error: Could not find a part of the path / Reading and Writing to files in ASP.Net TC ASP .Net 3 05-19-2004 12:00 AM
"Could not find a part of the path" error dsh ASP .Net 0 01-15-2004 09:58 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57