|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
CreateDirectory() - Could not find a part of the path "D:\".On a Windows 2000 Server when attempting to use System.IO.Directory.CreateDirectory(string.concat(Server.MapPath(""), "\verify")) I receive a System.IO.DirectoryNotFoundException error: Could not find a part of the path "D:\". The full path is "D:\hshome\clinton\test.gotchasoft.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\clinton. The user has modify access to d:\hshome\clinton\test.gotchasoft.com. Using the old Scripting.FileSystemObject.CreateFolder() using the same path name works fine. System.IO.Directory.DeleteDirectory() using the same path once created works fine. System.IO.Directory.SetCurrentDirectory(server.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 Hi Clinton,
Welcome to ASP.NET newsgroup. From your description, when you're using Directory.CreateDirectory to create sub dirs through the path retrieved by the Server.MapPath("") , you got ======== System.IO.DirectoryNotFoundException 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.) 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.CreateDirectory("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\clinton; the problem goes away. 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.) 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, UnauthorizedAccessException should be thrown, NOT DirectoryNotFoundException 2) non-standard permission behavior If I create a new windows login and the following folders: C:\PermTest\ C:\PermTest\user 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\user, 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, CreateDirectoryBehavior.CreateLastOnly) 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.CreateDirectory should explicity mention this behavior at the top of the page instead of implying it in the remarks section. I had the same problem ("DirectoryNotFoundException - 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.CreateDirectory() 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. I had the same problem ("DirectoryNotFoundException - 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.CreateDirectory() 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.
Other interesting topics
Q: visual studio .net
Can VS2003 and Visual Web Developer 2005 installed in the some machine? Validation jscript not firing on the deployment site Is it possible to pass an enum to a Web User Control? I cannot find my database using oledbConnection Why can I not use script blocks within ASP:Label controls? Solution while process is running Web Hits Call ATL from C# ASP.NET controlling button in headertemplate datagrid |
|||||||||||||||||||||||