Trouble creating new directory

S

Sheldon Cohen

Hello,
I am using c# and running a site that is on a shared
host. The code in question is supposed to create a new
directory that is coming out of a text box.

It works fine on my computer, but I get the following
stack trace:

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.DirectoryInfo.Create
() at testapps.createdir.CreateSubDirectory(String direc)

The code to create is as follows:

public bool CreateSubDirectory(string direc)
{
bool returnStatus = false;
DirectoryInfo di = new DirectoryInfo(@direc);
if(di.Exists)
{
Trace.Write("Directory exists " +
di.FullName);
this.Label1.Text = "Directory exists";
}
else
{
Trace.Write("Directory does not exist " +
di.FullName);
this.Label1.Text = "Directory does not
exists";
try
{
di.Create();
if(di.Exists)
{
Trace.Write("Directory exists
after creating it");
this.Label1.Text += "Directory
exists after creating it";
}
}
catch(Exception ex)
{
this.Label1.Text += "Error trying to
create directory that did not exist " + ex.ToString();
Trace.Write("Error creating directory
that does not exist " + ex);
}
}
return returnStatus;
}

Any ideas or suggestions, it works great on my local
machine?

Sheldon Cohen
(e-mail address removed)
 
R

Rick Strahl [MVP]

This may be a misnomer of an error, but I think the root of your problem (no
pun intended) is that you don't have permissions to get at data outside of
your configured directory on the Host server. Imagine if you could - you can
probe the entire server and scavage all the other site's files which would
be a bit of a security risk to say the least.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
 
S

Sheldon Cohen

Thanks, that makes sense. I have contacted my host and they do not have
a clue what to do. Any suggestions of how I could get this working?

Thanks,

Sheldon Cohen
 
R

Rick Strahl [MVP]

What do you need access to the root for?

Basically your domain probably runs under a specific user account they've
set up for you. That username needs rights to access the directories you
want to access. Since htey lock it down they should have a clue what to do
<g>...

+++ Rick --

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
 
S

Sheldon Cohen

Hi, thanks for responding back to my message.

I don't need root access I think, I am just trying to create a new
directory for each new user that matches a username they choose while
signing up from our website. We create a new jad file which is for their
java enabled cell phone. We are able to create the file using
StreamWriter and File.Create(), only the directory is giving us trouble.

The hosting company is not sure when we called them, they said they were
researching it. I have tried to use the
\\SERVER\OURUSERACCOUNTNAME\DIRECTORY but that gives us the message:
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.DirectoryInfo.Create
() at testapps.createdir.CreateSubDirectory(String direc)

We are really not sure what to do next. Seems like the
d:\inetput\wwwroot\OURUSERACCOUNTNAME\wwwRoot\jads which works when we
use the File.Create(PATH) does not work here.

Thanks for all the help so far, any more would be great.

Sheldon Cohen
 
R

Rick Strahl [MVP]

I think the problem may be share permissions. I had this problem once myself
where the root directory required directory read access or else shares
weren't accessible. I can't remember the details now exactly, but ultimately
it ended up being that I added EveryOne with directory read rights on the
root dir...

Bummer that htis is at an ISP which will make experimenting and trying to
find this issue a lot more work than if you can try it yourself <g>


+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top