How will you do it if you need to map path to a directory other than the root directory in c# application.

What I tried is:

public ActionResult Search()
    {
        var rootpath = Server.MapPath("~");
        var docpath = Path.GetFullPath(Path.Combine(rootpath, "../C:/Users/Rehan/Desktop/Pro Collection/xyz.pdf"));
        return File(Server.MapPath(docpath), "pdf");
    }

but unfortunately no avail.

Thanks in advance.

Related posts

Recent Viewed