473,574 Members | 2,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CreateDirectory () - Could not find a part of the path "D:\".

Hi,

On a Windows 2000 Server when attempting to use
System.IO.Direc tory.CreateDire ctory(string.co ncat(Server.Map Path(""),
"\verify"))
I receive a System.IO.Direc toryNotFoundExc eption error: Could not find a
part of the path "D:\".

The full path is "D:\hshome\clin ton\test.gotcha soft.com\verify "
The web is running using impersonation as a user on the local machine.
The user has no access to d:\, d:\hshome, or d:\hshome\clint on.
The user has modify access to d:\hshome\clint on\test.gotchas oft.com.

Using the old Scripting.FileS ystemObject.Cre ateFolder() using the same path
name works fine.
System.IO.Direc tory.DeleteDire ctory() using the same path once created works
fine.
System.IO.Direc tory.SetCurrent Directory(serve r.mappath("")) raises a similar
error but lists the entire folder structure rather than just the root.

I've seen similar posts accross the web, and have tried the following
suggestions:
Granting the "Bypass traverse checking" right to Everyone had no effect;
Granting the "Read Extended Attributes" to the D:\ drive had no effect.

This error is confirmed accross 38 Windows 2000 servers in an H-Sphere
(psoft.net) cluster, all with .NET Framework v1.1 installed.

Any help would be appreciated!

Clinton Frankland
Nov 19 '05 #1
9 13697
Hi Clinton,

Welcome to ASP.NET newsgroup.
From your description, when you're using Directory.Creat eDirectory to
create sub dirs through the path retrieved by the Server.MapPath( "") , you
got
========
System.IO.Direc toryNotFoundExc eption error: Could not find a part of the
path "D:\".
========

error. Also, you're suffering the problem on many other machines with the
same environement, yes?

Based on my loal test and the code sinppet, the problem is likely caused by
something with your environment. Would you help me confirm the following
things:

1. Does the problem occurs if you directly pass the full physical Path of
your application's virtual dir to the CreateDirectory function?

2. If still occurs, we may do some check on permission. How about turn off
impersonate and use the default process identity(should be machine\aspnet
for win2k server) and grant "modify/write" permission to that account. Test
again to see whether that can work. ( You can also test creating directory
through passing full qualified path when you swtich the process identity
and turn off impersonate).

BTW, to get the physical path of the root dir of our ASP.NET application,
we can use the
Server.MapPath( "~/"), this will be better than using the empty string which
only retrieve the relative path the current directory.

Please feel free to let me know if you got any new findings or need any
further help. Thanks,
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 19 '05 #2
Yes, the all the machines in the same environment have the same problem.

If I pass the full physical path the problem still occurs. Even testing
using the full string
Directory.Creat eDirectory("D:\ hshome\clinton\ test.gotchasoft .com\verify")
fails with the same error message.

This problem originally started using the default aspnet user (which again
did not have read access to the d:\ folder).

If I grant read access to d:\, d:\hshome, and d:\hshome\clint on; the problem
goes away.

Nov 19 '05 #3
Hi Clinton,

Thanks for your response. I think read access is necessary not only for the
application's virtual dir but also for the parent and root dir. This is
because the ASP.NET runtime will need to do monitoring on appliation's dir
and also parent dir (such as monitor the changing of web.config in all the
up level folders). Though I'm not sure this is the direct cause, but I'm
sure the read access must be granted to your asp.net 's executing account.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 19 '05 #4
I have just finished troubleshooting the same issue on one of our sites.
This concerns me for two reasons:

1) Misleading Exception thrown

Since the issue is caused by lack of permission for the ASPNET acct. to read
the parent folders, I would expect an UnauthorizedAcc essException, not
DirectoryNotFou ndException.

2) Non-standard behavior of permissions

If I create C:\PermTest\ and C:\PermTest\use r then grant full rights to the
\user folder and no read permission to C:\PermTest. I can view and create
folders, files, etc. in C:\PermTest\use r, but cannot view anything in
C:\PermTest. (Tested using a windows login acct. not the ASPNET acct.)

I would expect this same behavior with Directory.Creat eDirectory.

Insight from other developers implies that the CreateDirectory function's
behavior of creating a full path, not just the last directory in the given
path, is what is causing this. If it tries to look in C:\ (or D:\) to see if
the folder exists and is denied read access, then it appears to be failing
the CreateDirectory funciton entirely. For a good example see
http://hatka.net/wlogdev/archive/2004/08/29/178.aspx

Maybe a good solution would be two functions? CreateDirectory (string path) -
behaving this exact way for backwards compat. and CreateDirectory (string
path, CreateDirectory Behavior.LastDi rectoryOnly); or something to that affect.

Bryan Gerber
ASP.NET Developer

"Steven Cheng[MSFT]" wrote:
Hi Clinton,

Thanks for your response. I think read access is necessary not only for the
application's virtual dir but also for the parent and root dir. This is
because the ASP.NET runtime will need to do monitoring on appliation's dir
and also parent dir (such as monitor the changing of web.config in all the
up level folders). Though I'm not sure this is the direct cause, but I'm
sure the read access must be granted to your asp.net 's executing account.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 19 '05 #5
I just got done troubleshooting this error on one of our web applications.
There is a good source for this error and a good possible explanation at
http://hatka.net/wlogdev/archive/2004/08/29/178.aspx

This behavior concerns me for two reasons:

1) Wrong exception thrown

If the error is due to a lack of permission, UnauthorizedAcc essException
should be thrown, NOT DirectoryNotFou ndException

2) non-standard permission behavior

If I create a new windows login and the following folders:

C:\PermTest\
C:\PermTest\use r

Granting full perms to new user on \user folder and no perms on C:\PermTest,
the user CAN write files and create directories in C:\PermTest\use r, but
cannot read anything in C:\PermTest.
If I were fixing this, I might overload the CreateDirectory function to
support both behaviors:
CreateDirectory (string path) could remain as is
CreateDirectory (string path, CreateDirectory Behavior.Create LastOnly) could
ignore the first part of the path and just create the final folder in the
path string.

At the very least, I think that the MSDN documentation for
Directory.Creat eDirectory should explicity mention this behavior at the top
of the page instead of implying it in the remarks section.

Nov 19 '05 #6
Sorry for double post. Apparently, the post page lied to me when it said
there was an error posting my first message.
Nov 19 '05 #7
I had the same problem ("DirectoryNotF oundException - Could not find a
part of the path"), and found the remedy. If you search around, you'll
find that whenever this problem occurs, it's when someone is using a
drive other than C: - and usually these are locked down drives.

Apparently, Directory.Creat eDirectory() requires read and list contents
permissions on the root of the drive where the directory is being
created. The fix for me was to copy the permissions that I found on
the root of my C: drive to the root of my F: ( could be D:, etc) drive.

There is one permission set for Everyone on the C: drive, for "this
folder only" (not inherited), that gives Read & Execute permissions.
When I reproduced that permission set on my F: drive, this problem went
away. An important point is that by making this permission not
inherited into child folders and files, I don't have to worry about
opening up a big security hole.

Hope that helps,
John Crim
WebRelevance, Inc.

Nov 19 '05 #8
Dangit!!! I didn't think Google groups would post my email address....

Nov 19 '05 #9
I had the same problem ("DirectoryNotF oundException - Could not find a
part of the path"), and discovered the fix. If you search around,
you'll
find that whenever this problem occurs, it's when someone is using a
drive other than C: - and usually these are locked down drives.

Apparently, Directory.Creat eDirectory() requires read and list contents

permissions on the root of the drive where the directory is being
created. The fix for me was to copy the permissions that I found on
the root of my C: drive to the root of my F: ( could be D:, etc) drive.
There is one permission set for Everyone on the C: drive, for "this
folder only" (not inherited), that gives Read & Execute permissions.
When I reproduced that permission set on my F: drive, this problem went

away. An important point is that by making this permission not
inherited into child folders and files, I don't have to worry about
opening up a big security hole.
Hope that helps,
John Crim
WebRelevance, Inc.

Nov 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
10824
by: Karl Koscher | last post by:
I'm trying to communicate with a USB device using C#. I'm able to determine the device path using P/Invoke and SetupDiGetClassDevs, SetupDiEnumDeviceInterfaces, and SetupDiGetDeviceInterfaceDetail, but I can't open the device using File.Open. I get the following error: An unhandled exception of type 'System.ArgumentException' occurred in...
3
4131
by: Dmitry Jouravlev | last post by:
Hi, I have a number of C++ solutions in Visual Studio .NET and when i compile them using "Whole Program Optimization", certain projects report a LNK1171 error saying that c2.dll could not be loaded. The error contains the correct path to c2.dll (and it is definately there). This only happens on some projects and only when "whole program...
10
2173
by: Alpha | last post by:
I use FolderBrowserDlg for user to select a folder path then store it in the sql table. I then retrieve it to concatenate in a sqlcommand text to retrive files from that directory but it won't work because the database has it as "\\Support\VMS\VMSDB" while the C# code expects to see @"\\Support\\VMS\\VMSDB" . Is there a way to fix this? ...
1
1584
by: ±ù÷¢ | last post by:
I have a standard vb crystal reports viewer control on a web form with just the one simple report bound to it. when I run the project I get the following error: ACCESS TO THE PATH "DYNAMIC_IMAGES" IS DENIED. it goes on to say that the ASPNET account has got permission to access it etc etc so I have changed the permissions on everthing a...
0
1534
by: Martin | last post by:
Is this a known problem? Server Error in '/' Application. Could not find a part of the path "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\a12704fc\e427bb49\as8dko_g.0.cs". The base filename will be different on every next request.
1
1976
by: Michiel Schaeverbeke | last post by:
Hi, I'm trying to reach an xml file from within a web application. The file is physically on a different server. When I try to reach it using \\servername\path\ style, I get the error "\\servername\path\ is a physical path". Using a virtual directory gives the same result. All I really do is the following: // XmlTransformer is a...
0
1661
by: haylow | last post by:
Hi I am new to ASP.NET and am working on an application that runs on a webserver. The user will open up the web interface in a browser on their local machine and enter a path to a directory. I have 2 problems: First, I can't find a control that will let the user browse the file system and specify a directory - the only one I can find is...
2
5149
by: Guoqi Zheng | last post by:
Dear sir, I am trying to save a binary data by below script, however,it always give me an error of "Could not find a part of the path "C:\temp\". " Any idea what I did wrong here? Public Sub SaveAs(ByVal strPath As String)
3
8479
by: Nitinkcv | last post by:
Hi, While trying to run my app im getting the error Could not find a part of the path "c:\inetpub\wwwroot\Do not Delete\dbglobal.config". I checked and found that there is no Important_Do not Delete folder inside the wwwroot. The error occurs when i try to use the following code: //inside my test.aspx
0
7814
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7736
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8249
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7826
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8107
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5307
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3748
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3756
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.