Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Can you create a folder in ASP.net?

198 views
Skip to first unread message

Rick Strahl [MVP]

unread,
Apr 23, 2005, 7:55:00 PM4/23/05
to
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 ---

--

Rick Strahl
West Wind Technologies
www.west-wind.com/weblog
 
> 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

Roger Helliwell

unread,
Apr 23, 2005, 9:22:52 PM4/23/05
to
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

On Sat, 23 Apr 2005 15:57:16 -0700 in
microsoft.public.dotnet.framework.aspnet, "Rudy"

Rudy

unread,
Apr 24, 2005, 8:33:01 AM4/24/05
to
Thanks guys! Just what I needed.

Rudy

0 new messages