Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to use MapPath() function while uploading a file using FileUpload control

How to use MapPath() function while uploading a file using FileUpload control

Scheduled Pinned Locked Moved ASP.NET
helptutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    signbit
    wrote on last edited by
    #1

    i am creating a directory using code string path="C:/My Documents/"; Directory.CreateDirectory(path); directory is created successfully and i can view it in my c drive, now if i tries to upload a file using code if (FileUpload1.HasFile) { path += FileUpload1.FileName; FileUpload1.SaveAs(MapPath(path)); } it produces an error message showing "virtual path 'C:/My Documents/fileName' does not exists" while path do exists in my drive. any suggestion about the reason of this error. Thanks in advance.

    - A programmer's national anthem; "AAAAAHHHHH!!!!"

    S 1 Reply Last reply
    0
    • S signbit

      i am creating a directory using code string path="C:/My Documents/"; Directory.CreateDirectory(path); directory is created successfully and i can view it in my c drive, now if i tries to upload a file using code if (FileUpload1.HasFile) { path += FileUpload1.FileName; FileUpload1.SaveAs(MapPath(path)); } it produces an error message showing "virtual path 'C:/My Documents/fileName' does not exists" while path do exists in my drive. any suggestion about the reason of this error. Thanks in advance.

      - A programmer's national anthem; "AAAAAHHHHH!!!!"

      S Offline
      S Offline
      szukuro
      wrote on last edited by
      #2

      Mappath is used to get the physical path from a virtual one. In your case you already provide the physical path so you don't need to use the beforementioned method.

      S 1 Reply Last reply
      0
      • S szukuro

        Mappath is used to get the physical path from a virtual one. In your case you already provide the physical path so you don't need to use the beforementioned method.

        S Offline
        S Offline
        signbit
        wrote on last edited by
        #3

        thanks, it worked

        - A programmer's national anthem; "AAAAAHHHHH!!!!"

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups