Dummy needs help with MapPath

C

C not so sharp

Greetings!

I'm developing a file repository system in ASP.Net with C#. However, I am
having problems getting the environment to cooperate. Here is the scenario:

When a new user is created, I create their file folder as follows:

string strUserDir = "Dir"+ strNewID;
string strFileDir = ConfigurationSettings.AppSettings["DirectoryName"]; //
Defaults to "Uploads"

string strNewDir = "\\" + strFileDir + "\\" strUserDir;

if ( !Directory.Exists (Request.MapPath(.) + strNewDir ) )
{
Directory.CreateDirectory( Request.MapPath(.) + strNewDir();
}

This will create a folder called Dir10001 in the Uploads folder. However,
this is being created under the application root :

c:\inetpubs\wwwroot\Promotions
so it looks like c:\inetpub\wwwroot\PromotionsUploads\Dir10001.

I'd like it to create in c:\Uploads so it would look like
c:\Uploads\Dir10001.

How do I do this with MapPath?
 
M

mikeb

C said:
Greetings!

I'm developing a file repository system in ASP.Net with C#. However, I am
having problems getting the environment to cooperate. Here is the scenario:

When a new user is created, I create their file folder as follows:

string strUserDir = "Dir"+ strNewID;
string strFileDir = ConfigurationSettings.AppSettings["DirectoryName"]; //
Defaults to "Uploads"

string strNewDir = "\\" + strFileDir + "\\" strUserDir;

if ( !Directory.Exists (Request.MapPath(.) + strNewDir ) )
{
Directory.CreateDirectory( Request.MapPath(.) + strNewDir();
}

This will create a folder called Dir10001 in the Uploads folder. However,
this is being created under the application root :

c:\inetpubs\wwwroot\Promotions
so it looks like c:\inetpub\wwwroot\PromotionsUploads\Dir10001.

I'd like it to create in c:\Uploads so it would look like
c:\Uploads\Dir10001.

How do I do this with MapPath?

MapPath maps the web application path to the underlying file system path.

If you don't care where the web application is, then there's no reason
to use MapPath. Do something like:

"C:\\" + strFileDir + "\\" + strUserDir

I'd suggest that the "C:\\" string be configurable in some way (maybe
via web.config).
 
C

clintonG

No wonder you refer to yourself as 'not so sharp.'

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/



mikeb said:
C said:
Greetings!

I'm developing a file repository system in ASP.Net with C#. However, I am
having problems getting the environment to cooperate. Here is the scenario:

When a new user is created, I create their file folder as follows:

string strUserDir = "Dir"+ strNewID;
string strFileDir = ConfigurationSettings.AppSettings["DirectoryName"]; //
Defaults to "Uploads"

string strNewDir = "\\" + strFileDir + "\\" strUserDir;

if ( !Directory.Exists (Request.MapPath(.) + strNewDir ) )
{
Directory.CreateDirectory( Request.MapPath(.) + strNewDir();
}

This will create a folder called Dir10001 in the Uploads folder. However,
this is being created under the application root :

c:\inetpubs\wwwroot\Promotions
so it looks like c:\inetpub\wwwroot\PromotionsUploads\Dir10001.

I'd like it to create in c:\Uploads so it would look like
c:\Uploads\Dir10001.

How do I do this with MapPath?

MapPath maps the web application path to the underlying file system path.

If you don't care where the web application is, then there's no reason
to use MapPath. Do something like:

"C:\\" + strFileDir + "\\" + strUserDir

I'd suggest that the "C:\\" string be configurable in some way (maybe
via web.config).
 
K

Kevin Spencer

No wonder you refer to yourself as 'not so sharp.'

I'm afraid, Clinton, that you may have to refer to yourself in the future as
"not so kind." That was uncalled-for. :(

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

clintonG said:
No wonder you refer to yourself as 'not so sharp.'

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/



mikeb said:
C said:
Greetings!

I'm developing a file repository system in ASP.Net with C#. However, I am
having problems getting the environment to cooperate. Here is the scenario:

When a new user is created, I create their file folder as follows:

string strUserDir = "Dir"+ strNewID;
string strFileDir = ConfigurationSettings.AppSettings["DirectoryName"]; //
Defaults to "Uploads"

string strNewDir = "\\" + strFileDir + "\\" strUserDir;

if ( !Directory.Exists (Request.MapPath(.) + strNewDir ) )
{
Directory.CreateDirectory( Request.MapPath(.) + strNewDir();
}

This will create a folder called Dir10001 in the Uploads folder. However,
this is being created under the application root :

c:\inetpubs\wwwroot\Promotions
so it looks like c:\inetpub\wwwroot\PromotionsUploads\Dir10001.

I'd like it to create in c:\Uploads so it would look like
c:\Uploads\Dir10001.

How do I do this with MapPath?

MapPath maps the web application path to the underlying file system path.

If you don't care where the web application is, then there's no reason
to use MapPath. Do something like:

"C:\\" + strFileDir + "\\" + strUserDir

I'd suggest that the "C:\\" string be configurable in some way (maybe
via web.config).
 
C

clintonG

When somebody uses self-deprecation I think they are joking
around so I agreed he or she is not in fact so sharp. If its any
consolation I am in a perpetual state of not being so sharp
myself as achieving a mastery of C# and the .NET Framework
is very challenging.

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/


Kevin Spencer said:
No wonder you refer to yourself as 'not so sharp.'

I'm afraid, Clinton, that you may have to refer to yourself in the future as
"not so kind." That was uncalled-for. :(

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

clintonG said:
No wonder you refer to yourself as 'not so sharp.'

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/



mikeb said:
C not so sharp wrote:
Greetings!

I'm developing a file repository system in ASP.Net with C#. However, I am
having problems getting the environment to cooperate. Here is the scenario:

When a new user is created, I create their file folder as follows:

string strUserDir = "Dir"+ strNewID;
string strFileDir = ConfigurationSettings.AppSettings["DirectoryName"]; //
Defaults to "Uploads"

string strNewDir = "\\" + strFileDir + "\\" strUserDir;

if ( !Directory.Exists (Request.MapPath(.) + strNewDir ) )
{
Directory.CreateDirectory( Request.MapPath(.) + strNewDir();
}

This will create a folder called Dir10001 in the Uploads folder. However,
this is being created under the application root :

c:\inetpubs\wwwroot\Promotions
so it looks like c:\inetpub\wwwroot\PromotionsUploads\Dir10001.

I'd like it to create in c:\Uploads so it would look like
c:\Uploads\Dir10001.

How do I do this with MapPath?


MapPath maps the web application path to the underlying file system path.

If you don't care where the web application is, then there's no reason
to use MapPath. Do something like:

"C:\\" + strFileDir + "\\" + strUserDir

I'd suggest that the "C:\\" string be configurable in some way (maybe
via web.config).
 

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,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top