473,387 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem Creating Directory

Hello,

The following error is appearing when attempting to create a directory
using the availale system.io methods:

System.IO.DirectoryNotFoundException: Could not find a part of the
path "D:\". at System.IO.__Error.WinIOError(Int32 errorCode, String
str) at System.IO.Directory.InternalCreateDirectory(String fullPath,
String path) at System.IO.Directory.CreateDirectory(String path) at
TestVBProject.createdirectorytest.Page_Load(Object sender, EventArgs
e)

The code works fine in my test environment (wide open permissions) but
fails on the production server at the hosting facility. We have tried
giving full permissions to the aspnet account and it still fails.
Windows 2003 is used on the production server.

Because there are shared users on the server, I am afraid to try
changing the user in machine.config to SYSTEM, but if that should be
attempted, let me know.

Any help on the matter is appreciated.

Thanks.
Nov 18 '05 #1
3 2268
Hi,

If you are using Windows 2003, then its not the ASPNet account who is
actually executing the thread that is trying to create the folder. Its the
user account that is running the application pool bound to the IIS
application. This has changed from Windows 2000. Look in the properties of
the application pool, identity tab.

Also, if you want to confirm this, use the following in one of your .aspx
pages to see who its running as.

//sample
Response.Write("Current executing thread is " +
System.Security.Principal.WindowsIdentity.GetCurre nt().Name);

Michael

--
This posting is provided "AS IS" with no warranties, and confers no rights.
"James Coleman" <ja*************@gmail.com> wrote in message
news:d1**************************@posting.google.c om...
Hello,

The following error is appearing when attempting to create a directory
using the availale system.io methods:

System.IO.DirectoryNotFoundException: Could not find a part of the
path "D:\". at System.IO.__Error.WinIOError(Int32 errorCode, String
str) at System.IO.Directory.InternalCreateDirectory(String fullPath,
String path) at System.IO.Directory.CreateDirectory(String path) at
TestVBProject.createdirectorytest.Page_Load(Object sender, EventArgs
e)

The code works fine in my test environment (wide open permissions) but
fails on the production server at the hosting facility. We have tried
giving full permissions to the aspnet account and it still fails.
Windows 2003 is used on the production server.

Because there are shared users on the server, I am afraid to try
changing the user in machine.config to SYSTEM, but if that should be
attempted, let me know.

Any help on the matter is appreciated.

Thanks.

Nov 18 '05 #2
Thanks for the reply. I had already checked out the account and found
that it wasn't the aspnet account, but giving the correct account full
permissions to the directory didn't solve the problem.

The solution to the problem was to give the calling account
permissions to the root directory, not just the root of the website.
The hosting facility, however, is not willing to grant me these
permissions, so I'm in a pickle.

I've tried running batch files and or calling the command line via
system.diagnostics.process, but it doesn't work either.

The hosting facility claimed it was a bug with Win2003. I don't know.
All I want to do is create a directory! I'm not that experience with
com, but wonder if I need to create an unmanaged com object to do it
and then call that in .net.

How can I get around needing access to the root? Apparently one
company was able to solve it:
http://support.mathsoft.com/mas/article.asp?id=893

I don't know how they did it however.

Thanks,

James
"Michael O'Donovan [MSFT]" <mi******@online.microsoft.com> wrote in message news:<eN**************@TK2MSFTNGP11.phx.gbl>...
Hi,

If you are using Windows 2003, then its not the ASPNet account who is
actually executing the thread that is trying to create the folder. Its the
user account that is running the application pool bound to the IIS
application. This has changed from Windows 2000. Look in the properties of
the application pool, identity tab.

Also, if you want to confirm this, use the following in one of your .aspx
pages to see who its running as.

//sample
Response.Write("Current executing thread is " +
System.Security.Principal.WindowsIdentity.GetCurre nt().Name);

Michael

--
This posting is provided "AS IS" with no warranties, and confers no rights.
"James Coleman" <ja*************@gmail.com> wrote in message
news:d1**************************@posting.google.c om...
Hello,

The following error is appearing when attempting to create a directory
using the availale system.io methods:

System.IO.DirectoryNotFoundException: Could not find a part of the
path "D:\". at System.IO.__Error.WinIOError(Int32 errorCode, String
str) at System.IO.Directory.InternalCreateDirectory(String fullPath,
String path) at System.IO.Directory.CreateDirectory(String path) at
TestVBProject.createdirectorytest.Page_Load(Object sender, EventArgs
e)

The code works fine in my test environment (wide open permissions) but
fails on the production server at the hosting facility. We have tried
giving full permissions to the aspnet account and it still fails.
Windows 2003 is used on the production server.

Because there are shared users on the server, I am afraid to try
changing the user in machine.config to SYSTEM, but if that should be
attempted, let me know.

Any help on the matter is appreciated.

Thanks.

Nov 18 '05 #3
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 worker 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

"James Coleman" <ja*************@gmail.com> wrote in message news:d1**************************@posting.google.c om...
Thanks for the reply. I had already checked out the account and found
that it wasn't the aspnet account, but giving the correct account full
permissions to the directory didn't solve the problem.

The solution to the problem was to give the calling account
permissions to the root directory, not just the root of the website.
The hosting facility, however, is not willing to grant me these
permissions, so I'm in a pickle.

I've tried running batch files and or calling the command line via
system.diagnostics.process, but it doesn't work either.

The hosting facility claimed it was a bug with Win2003. I don't know.
All I want to do is create a directory! I'm not that experience with
com, but wonder if I need to create an unmanaged com object to do it
and then call that in .net.

How can I get around needing access to the root? Apparently one
company was able to solve it:
http://support.mathsoft.com/mas/article.asp?id=893

I don't know how they did it however.

Thanks,

James


"Michael O'Donovan [MSFT]" <mi******@online.microsoft.com> wrote in message news:<eN**************@TK2MSFTNGP11.phx.gbl>...
Hi,

If you are using Windows 2003, then its not the ASPNet account who is
actually executing the thread that is trying to create the folder. Its the
user account that is running the application pool bound to the IIS
application. This has changed from Windows 2000. Look in the properties of
the application pool, identity tab.

Also, if you want to confirm this, use the following in one of your ..aspx
pages to see who its running as.

//sample
Response.Write("Current executing thread is " +
System.Security.Principal.WindowsIdentity.GetCurre nt().Name);

Michael

--
This posting is provided "AS IS" with no warranties, and confers no rights.
"James Coleman" <ja*************@gmail.com> wrote in message
news:d1**************************@posting.google.c om...
Hello,

The following error is appearing when attempting to create a directory
using the availale system.io methods:

System.IO.DirectoryNotFoundException: Could not find a part of the
path "D:\". at System.IO.__Error.WinIOError(Int32 errorCode, String
str) at System.IO.Directory.InternalCreateDirectory(String fullPath,
String path) at System.IO.Directory.CreateDirectory(String path) at
TestVBProject.createdirectorytest.Page_Load(Object sender, EventArgs
e)

The code works fine in my test environment (wide open permissions) but
fails on the production server at the hosting facility. We have tried
giving full permissions to the aspnet account and it still fails.
Windows 2003 is used on the production server.

Because there are shared users on the server, I am afraid to try
changing the user in machine.config to SYSTEM, but if that should be
attempted, let me know.

Any help on the matter is appreciated.

Thanks.

Nov 18 '05 #4

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

Similar topics

1
by: timothy.williams | last post by:
I'm trying to install wxPython 2.5.3.1 using Python 2.3.2 on a Fedora 2 machine. I have python in a non-standard place, but I'm using --prefix with the configure script to point to where I have...
3
by: Jagdip Singh | last post by:
Hi, We are facing problem accessing to DB2. Seems like database manager is down I tried starting it using db2start but it was neither showing any messages nor returning to command prompt...
4
by: | last post by:
Hi, all: I have a RedHat 9 with gcc version 3.4.1, and I want to compile siph323csgw with ¡§make siph323csgw¡¨. But when I compile siph323csgw, I get this message: configure: creating...
8
by: nick | last post by:
I have a problem and I've been using a cheezy work around and was wondering if anyone else out there has a better solution. The problem: Let's say I have a web application appA. Locally, I set...
5
by: יוני גולדברג | last post by:
Hi, While trying to create new directory i recieve the following error message: "System.IO.DirectoryNotFoundException: Could not find a part of the path "\\premfs16\sites". The path exists, even...
2
by: Richard Lionheart | last post by:
Hi All, I generated a WebForm and created a Virtual Directory for it IIS. But I got an error message (shown below) saying something like my app lacked appropriate privileges. David Wang...
1
by: Medora Schauer | last post by:
I've installed 7.4.2 on a PowerPC system running linux 2.4.13. When I try to run initdb to create to create the database cluster I get the following: $ initdb -D $PGDATA The files...
2
by: tech tech | last post by:
Hello All, I installed postgresql 7.3.4 on HPUX PA in /usr/local/pgsql and put the libraries in /usr/local/pgsql/lib/LIB_new. During the initialization( initdb), it loads libraries (language)...
1
by: John_Baptist | last post by:
Hello, I have created a virtual directory in IIS 6.0 with the name JohnASP . Now my problem is when i'm creating new ASP.NET project in MSVS .NET in the location place which name i should...
1
by: Richard | last post by:
Hi, I created a new directory on my WinXP-Pro/SP2 file system. Then I created a virtual directory in IIS pointing to that local directory. After completing that, I noticed that I had a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.