Problem With Paths on Server

Discussion in 'ASP.NET / ASP.NET Core' started by wengert, Sep 18, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I am having a problem attempting to upload a file using the HtmlInputFile control. Using the control I can successfully browse to the file on my local machine but when I try to upload it to one of my directories I always get the error:

    Could not find a part of the path "E:\web\westernband\htdocs\lineups\"

    If I open an FTP application I see the "lineups" directory directly under my root (westernband) but apparently Server.Mappath returns a different result? The code I use to determine the path is:




    uploadedfile.PostedFile.SaveAs(Server.MapPath("\lineups\" & newfilename))





    I am not sure why there is the "htdocs" directory in that path and I am wondering if that is the problem?





    How should I code this?





    Wayne

    ------------
    Wayne
     
  2. See if this works for you:

    Dim strFileName as string = File1.PostedFile.FileName
    ' upload path and file
    dim UploadFile as string = Server.MapPath('\lineups\' & System.IO.Path.GetFileName(strFileName)
    File1.PostedFile.SaveAs(UploadFile)

    Note 'File1' is the id of the Input field for the file name.
     
  3. Thanks for the response. I'll give that approach a try.


    ------------
    Wayne
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page