File Path Mapping VB .NET

Discussion in 'ASP.NET 2.0' started by Skawt, Feb 18, 2013.

  1. I have a webpage that allows the user to upload a file, then processes it.

    When running on my local host I can map the uploaded file to C:\blah\blah etc.

    What is the correct way to map the path for a file on a discountasp.net hosted account?

    Thank you!
     
  2. Check out the Account Info/Edit section of your Control Panel, that will show the direct path to your hosting space, you can either use that file path as part of the target directory where your file upload scripts uploads to, or you can use something like "~/Upload" where Upload is a directory you created with FTP that is on the same "level" as your upload script.
     
  3. Hi Skawt,
    If I understand your question correctly, you are trying to get the path to a specific folder in your DASP web folder. I struggled with this for a while myself, and eventually found that Server.Mappath was the most reliable solution. For a great explanation (helped me, anyway), check out this link.
    http://stackoverflow.com/questions/275781/server-mappath-server-mappath-server-mappath-server-mappath

    Now I typically use code like
    Code:
    dim folderName as string = "MyFolderName"
    dim fileName as string ="blah.txt"
    dim fullPath as string = Server.Mappath (IO.Path.Combine(folderName, fileName)) 
    for the most reliable targeting of a file.

    I work in .NET 4.0, but I'm pretty sure Mappath is available in .NET 2.0, though Combine may not.

    Good luck!
     

Share This Page