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. FileInfo-----local machince vs/Hosting machine---help needed

FileInfo-----local machince vs/Hosting machine---help needed

Scheduled Pinned Locked Moved ASP.NET
visual-studiosysadminhostingalgorithmshelp
5 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.
  • N Offline
    N Offline
    Naveed Kamboh
    wrote on last edited by
    #1

    Hi Friends, I am trying to read file info using following code. When i run it on my local machine it works 100% but when I upload it to hosting server it throws exception!! or in other words it goes to else all the time can any one hlep me why? string fileOpenPath =this.FileUpload1.FileName.ToString(); FileInfo fi = new FileInfo(fileOpenPath); //Ceck if file file exists if (fi.Exists ) { //do some work } else { //show message }

    Naveed Kamboh Complexity kills, Write easy code for your self. isolutionteam

    G 1 Reply Last reply
    0
    • N Naveed Kamboh

      Hi Friends, I am trying to read file info using following code. When i run it on my local machine it works 100% but when I upload it to hosting server it throws exception!! or in other words it goes to else all the time can any one hlep me why? string fileOpenPath =this.FileUpload1.FileName.ToString(); FileInfo fi = new FileInfo(fileOpenPath); //Ceck if file file exists if (fi.Exists ) { //do some work } else { //show message }

      Naveed Kamboh Complexity kills, Write easy code for your self. isolutionteam

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      That's because the file doesn't exist on the server. You can't use a file path that references a file on the client computer to access a file on the server. When you are running it on your own computer, the client and the server is the same, so the file that exists on the client also exists on the server.

      --- single minded; short sighted; long gone;

      N 1 Reply Last reply
      0
      • G Guffa

        That's because the file doesn't exist on the server. You can't use a file path that references a file on the client computer to access a file on the server. When you are running it on your own computer, the client and the server is the same, so the file that exists on the client also exists on the server.

        --- single minded; short sighted; long gone;

        N Offline
        N Offline
        Naveed Kamboh
        wrote on last edited by
        #3

        Could you please help me how can i do that then. some Code please

        Naveed Kamboh Complexity kills, Write easy code for your self. isolutionteam

        N G 2 Replies Last reply
        0
        • N Naveed Kamboh

          Could you please help me how can i do that then. some Code please

          Naveed Kamboh Complexity kills, Write easy code for your self. isolutionteam

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          The FileUpload object contains the data from the uploaded file. Get the data from there, and if you need it as a file, create a file and write the data to it.

          --- single minded; short sighted; long gone;

          1 Reply Last reply
          0
          • N Naveed Kamboh

            Could you please help me how can i do that then. some Code please

            Naveed Kamboh Complexity kills, Write easy code for your self. isolutionteam

            N Offline
            N Offline
            Naveed Kamboh
            wrote on last edited by
            #5

            Thanks , I've sorted.

            Naveed Kamboh Complexity kills, Write easy code for your self. isolutionteam

            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