Can you create a folder in ASP.net?

G

Guest

Hello All!

Can you dynamicly create a folder in ASP.net? Here is the set up. I have a
folder where I will store pics. What I would like to do is create a cookie,
track the user who has logged on to the site. If user deside to upload
pictures under thier profile, a subfolder under the images folder will be
created with the folder name as the users name. I would like to keep the pics
seperatred for each user.
TIA!!

Rudy
 
R

Rick Strahl [MVP]

Hi Rudy,

Yes you can *if* you have the rights to do so. ASP.NET runs under a designated account (usually ASPNET on IIS5 or NETWORK SERVICE on IIS6) and this account will need rights to be able to create a directory in that folder where you need to create it. By default the accounts used do not have this permission, so you would likely have to add it.

To see what account your app is running under you can use:

Response.Write(Environment.Username);

to know which account needs the permissions in question.

+++ Rick ---
 
R

Roger Helliwell

Hi,

In addition to what Rick mentioned about ASP file permissions, the
actual code to create a folder would be similar to:

System.IO.Directory.CreateDirectory(Server.MapPath("images\\" +
Profile.UserName));
// Don't forget to check for IO errors ;)

Roger
 
G

Guest

Thanks guys! Just what I needed.

Rudy

Roger Helliwell said:
Hi,

In addition to what Rick mentioned about ASP file permissions, the
actual code to create a folder would be similar to:

System.IO.Directory.CreateDirectory(Server.MapPath("images\\" +
Profile.UserName));
// Don't forget to check for IO errors ;)

Roger
 

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

Top