Server.MapPath Question

Posted on 2008-11-14
Last Modified: 2013-11-05
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?
Question by:sbornstein2
    LVL 20

    Expert Comment


    If the path is relative to the application, like the usage of Server.MapPath suggests, it should be:
    And it should work assuming that there is a folder or VDIR called "FileUpload" in the root of the application directory.

    Author Comment

    can I create a directory say under my C drive and then create a virtual directory for it under default web site?
    LVL 20

    Accepted Solution

    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")


    Author Closing Comment


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now