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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Not able to save the file of HttpPostedfile from test method

Not able to save the file of HttpPostedfile from test method

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpasp-netarchitecturehelp
2 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.
  • V Offline
    V Offline
    vnr
    wrote on last edited by
    #1

    Hi, I am working on an MVC application which is written in c#. I am not able to save the httpposted file to my local folder while running the test case.But the same I am able to run from my controller and its working fine.Pelase find the code below. string savePath ="c:/test.xlsx"; HttpPostedFileBase uploadedFile = files[0] as HttpPostedFileBase; uploadedFile.SaveAs(savePath); //not saving the file to the path can anyone pls help me on this. Thanks in advance.

    M 1 Reply Last reply
    0
    • V vnr

      Hi, I am working on an MVC application which is written in c#. I am not able to save the httpposted file to my local folder while running the test case.But the same I am able to run from my controller and its working fine.Pelase find the code below. string savePath ="c:/test.xlsx"; HttpPostedFileBase uploadedFile = files[0] as HttpPostedFileBase; uploadedFile.SaveAs(savePath); //not saving the file to the path can anyone pls help me on this. Thanks in advance.

      M Offline
      M Offline
      MicroVirus
      wrote on last edited by
      #2

      I don't know what operating system you are running, but after Windows XP the root directory has become protected. Software normally can't write to it without acquiring permissions first. Try creating a directory C:\Test and then try saving to C:\Test\Text.xlsx. Also, you can check the return value or catch exceptions SaveAs throws so you can find out more about the specific error. My guess now is that it would be 'access denied'.

      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