Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6889785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:11:59+00:00 2026-05-27T06:11:59+00:00

I have a little question about my URL . I use a tree view

  • 0

I have a little question about my URL .

I use a tree view on my asp page that’s why I use this getcurrentdirectory .

//DirectoryInfo di = new DirectoryInfo("~" + GetTheCurrentDirectory
(selectedNodeValue));
~ = C://Inetpub//WwwRoot//
GetTheCurrentDirectory = Projects//Folder1//

So for the moment it’s fine because i Can load all the files for a folder.

After I try to download the files when you click on it .

protected void Page_Load(object sender, EventArgs e)
{
    string path = Request["path"].ToString();
    string filename = Request["file"].ToString();

    fileDownload(filename, Server.MapPath("~\\" + path + filename));
}

So I can retrieve the Path wich is the current directory . The method I use in my other page.

In the server.MapPatch should I put ~ also ? Because when I do that is works localy, but when I put this on my server , the downloading part doesn’t work so I suppose this is a URL issue, I can’t debug so I am really lost about this !

I changed some things :

DirectoryInfo di = new DirectoryInfo(GetTheCurrentDirectory(selectedNodeValue));

So its returns the same thing .

So now in the server.MapPath the path equal something like Projects//Folder 1//

It works locally, but still not on the server …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:12:00+00:00Added an answer on May 27, 2026 at 6:12 am

    Try this:

    fileDownload(filename, Server.MapPath("~/" + path + filename));
    

    And also, as a best practice, don’t use + to concatenate strings. You should use string.format, so I would write the above line as follows:

    fileDownload(filename, Server.MapPath(string.format("~/{0}{1}", path, filename)));
    

    Just to help you understand your problem better, Server.MapPath will return you a physical file path on the server which corresponds to the virtual path on the web server. i.e. it converts “http://website.com/img.jpg” to something like “C:\mywebsite\img.jpg”

    UPDATE:
    Make sure the folder you’re trying to save the file to, is not read-only and you have permissions to create files in the folder.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have little question about how web browser retrieve webpage? I know this User
I have this little question that's been on my mind for a while now.
I asked a little while ago a question about rollback, I have a new
So, this question may be a little vague, but I have constant discussions about
Little question about Ruby error handling. I have some code that roughly resembles the
I have a little question to community. Does ASP.NET MVC allow to execute an
This question may seem a little bit stackoverflow-implementation specific, but I have seen a
i have a little question about the verbatim environment in latex..... my problem is
Forgive me if this question makes little sense; I have had little sleep as
This question about unit tests sparked another thing that's been bothering me. I've gone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.