Creating new directory on the server

  • Thread starter Thread starter rsimlote
  • Start date Start date
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
 
How can I create a directory programatically through ASP.NET code?

System.IO.Directory.CreateDirectory(<a physical path>); should work.
 
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
 
Back
Top