Creating new directory on the server

R

rsimlote

Hi
I am developing a site, where the users upload images to the user's
(/images/<username>) directory on the server. I am able to upload the
file only if the directory already exist on the server, but for that I
am manually craeting these directories on the server. How can I create
a directory programatically through ASP.NET code? Thanks.
Rahul
 
P

Paul Henderson

How can I create a directory programatically through ASP.NET code?

System.IO.Directory.CreateDirectory(<a physical path>); should work.
 
N

Norman Crandall

To get the physical path you can user server.mappath("/images/username/")

Norm
 
R

RS

Hi Norman,
Thanks for replying. I tried doing what you suggested. I used
Server.MapPath(path), but the problem is that it gives me path
"C:\Inetpub\wwwroot\applname\images\username", which is correct
however, it creats the directory and stores image on the client's
machine. As I my development machine is also the development server as
well as client for local testing, things were working fine, until I
transferred my files on the production testing server, and the
directories were still created on the client machine. Please help on
how to get the server location, Thanks.
Rahul
 

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,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top