• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

Server.MapPath Question

If I have the following:  Server.MapPath("\\FileUpload\") how do I set that up?  It is in existing code and and it cant find the path, do I need to create a directory through IIS or something?
0
sbornstein2
Asked:
sbornstein2
  • 2
  • 2
1 Solution
 
Juan_BarreraCommented:
Hi,

If the path is relative to the application, like the usage of Server.MapPath suggests, it should be:
Server.MapPath("~/FileUpload")
And it should work assuming that there is a folder or VDIR called "FileUpload" in the root of the application directory.
0
 
sbornstein2Author Commented:
can I create a directory say under my C drive and then create a virtual directory for it under default web site?
0
 
Juan_BarreraCommented:
Yes, sure:
1) Create the physical directory under C:\|. Let's say you call it "FileUpload"
2) Give the account, under which the website's app pool is running, the appropriate permissions to it (usually read / write).
3) Create the VDIR in IIS, pointing to the physical directory.
4) Now, you can reference it by using HttpContext.Current.Server.MapPath("~/FileUpload")

0
 
sbornstein2Author Commented:
thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now