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. Web Development
  3. ASP.NET
  4. Retrieving files from web server

Retrieving files from web server

Scheduled Pinned Locked Moved ASP.NET
helpsysadminhosting
7 Posts 3 Posters 1 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.
  • M Offline
    M Offline
    mukesh mr03
    wrote on last edited by
    #1

    hi, i'm facing a problem in retreiving files from server. i have posted some files in a folder in my web server. while running the program it will show all the filenames in a dropdown list. i want to open a file while selecting the file name. its working in localhost but its not working after hosting the page. plz help me

    N S 2 Replies Last reply
    0
    • M mukesh mr03

      hi, i'm facing a problem in retreiving files from server. i have posted some files in a folder in my web server. while running the program it will show all the filenames in a dropdown list. i want to open a file while selecting the file name. its working in localhost but its not working after hosting the page. plz help me

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      mukesh.mr03 wrote:

      its working in localhost but its not working after hosting the page.

      Opening means just showing redirecting to the file and prompting for a download ? or opening the file using any file methods ? Can you post the code you used for this ?

      All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

      M 1 Reply Last reply
      0
      • M mukesh mr03

        hi, i'm facing a problem in retreiving files from server. i have posted some files in a folder in my web server. while running the program it will show all the filenames in a dropdown list. i want to open a file while selecting the file name. its working in localhost but its not working after hosting the page. plz help me

        S Offline
        S Offline
        Shujaat Ullah Khan
        wrote on last edited by
        #3

        the path you are giving must be of local file system.Try to download the file at client side and then open it.

        Shujaat

        M 1 Reply Last reply
        0
        • N N a v a n e e t h

          mukesh.mr03 wrote:

          its working in localhost but its not working after hosting the page.

          Opening means just showing redirecting to the file and prompting for a download ? or opening the file using any file methods ? Can you post the code you used for this ?

          All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

          M Offline
          M Offline
          mukesh mr03
          wrote on last edited by
          #4

          this is the code i'm using in it. i have to open the file in any way(download or open) DirectoryInfo di = new DirectoryInfo(Server.MapPath("Data/")); string pa = di.ToString(); if (di.Exists == false) { di.Create(); } FileStream fs = new FileStream(di + "/" + DropDownList1.SelectedItem.Text, FileMode.Open); fs.Seek(0, SeekOrigin.Begin); fs.Close(); ProcessStartInfo psi = new ProcessStartInfo(di + "/" + DropDownList1.SelectedItem.Text); Process.Start(psi);

          N 1 Reply Last reply
          0
          • S Shujaat Ullah Khan

            the path you are giving must be of local file system.Try to download the file at client side and then open it.

            Shujaat

            M Offline
            M Offline
            mukesh mr03
            wrote on last edited by
            #5

            this is the code i'm using in it. DirectoryInfo di = new DirectoryInfo(Server.MapPath("Data/")); string pa = di.ToString(); if (di.Exists == false) { di.Create(); } FileStream fs = new FileStream(di + "/" + DropDownList1.SelectedItem.Text, FileMode.Open); fs.Seek(0, SeekOrigin.Begin); fs.Close(); ProcessStartInfo psi = new ProcessStartInfo(di + "/" + DropDownList1.SelectedItem.Text); Process.Start(psi);

            1 Reply Last reply
            0
            • M mukesh mr03

              this is the code i'm using in it. i have to open the file in any way(download or open) DirectoryInfo di = new DirectoryInfo(Server.MapPath("Data/")); string pa = di.ToString(); if (di.Exists == false) { di.Create(); } FileStream fs = new FileStream(di + "/" + DropDownList1.SelectedItem.Text, FileMode.Open); fs.Seek(0, SeekOrigin.Begin); fs.Close(); ProcessStartInfo psi = new ProcessStartInfo(di + "/" + DropDownList1.SelectedItem.Text); Process.Start(psi);

              N Offline
              N Offline
              N a v a n e e t h
              wrote on last edited by
              #6

              mukesh.mr03 wrote:

              ProcessStartInfo psi = new ProcessStartInfo(di + "/" + DropDownList1.SelectedItem.Text); Process.Start(psi);

              This looks fine in the case of desktop applications. But in ASP.NET , Process.Start() can't start a process in clients machine, because ASP.NET it works on server. You can redirect to the file instead, which forces browser to open a save dialog box, and user can download the file to his/her system. Use

              Response.Redirect("Data/" + DropDownList1.SelectedItem.Text);

              mukesh.mr03 wrote:

              DirectoryInfo di = new DirectoryInfo(Server.MapPath("Data/")); string pa = di.ToString(); if (di.Exists == false)

              Out of Topic : There is no need to use DirectoryInfo for checking directory existence. Directory class provides a static methods which checks directory existence.

              All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

              M 1 Reply Last reply
              0
              • N N a v a n e e t h

                mukesh.mr03 wrote:

                ProcessStartInfo psi = new ProcessStartInfo(di + "/" + DropDownList1.SelectedItem.Text); Process.Start(psi);

                This looks fine in the case of desktop applications. But in ASP.NET , Process.Start() can't start a process in clients machine, because ASP.NET it works on server. You can redirect to the file instead, which forces browser to open a save dialog box, and user can download the file to his/her system. Use

                Response.Redirect("Data/" + DropDownList1.SelectedItem.Text);

                mukesh.mr03 wrote:

                DirectoryInfo di = new DirectoryInfo(Server.MapPath("Data/")); string pa = di.ToString(); if (di.Exists == false)

                Out of Topic : There is no need to use DirectoryInfo for checking directory existence. Directory class provides a static methods which checks directory existence.

                All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

                M Offline
                M Offline
                mukesh mr03
                wrote on last edited by
                #7

                thank you. its working..

                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