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. filedownloading [modified]

filedownloading [modified]

Scheduled Pinned Locked Moved ASP.NET
7 Posts 3 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
    Sunil Wise
    wrote on last edited by
    #1

    hi frns i have developed one application in that i have one gridview in that i have one column (filename)with hyperlink when i click on that link i am getting the filedownload window asking to save or open but i want the file to be displayed directly instead of asking in the browser. any suggestions grately appreciated regards :)sunilwise -- modified at 4:35 Thursday 15th November, 2007

    C P 2 Replies Last reply
    0
    • S Sunil Wise

      hi frns i have developed one application in that i have one gridview in that i have one column (filename)with hyperlink when i click on that link i am getting the filedownload window asking to save or open but i want the file to be displayed directly instead of asking in the browser. any suggestions grately appreciated regards :)sunilwise -- modified at 4:35 Thursday 15th November, 2007

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Link to a page which takes the filename off the URL and does a Response.BinaryWrite to send the file into the browser to be displayed.

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      S 1 Reply Last reply
      0
      • C Christian Graus

        Link to a page which takes the filename off the URL and does a Response.BinaryWrite to send the file into the browser to be displayed.

        Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        S Offline
        S Offline
        Sunil Wise
        wrote on last edited by
        #3

        its working in local system but if i try to open it in another system which is connected through lan again that filedownload window is opening sir

        C 1 Reply Last reply
        0
        • S Sunil Wise

          hi frns i have developed one application in that i have one gridview in that i have one column (filename)with hyperlink when i click on that link i am getting the filedownload window asking to save or open but i want the file to be displayed directly instead of asking in the browser. any suggestions grately appreciated regards :)sunilwise -- modified at 4:35 Thursday 15th November, 2007

          P Offline
          P Offline
          Prateek G
          wrote on last edited by
          #4

          If you are using Response.AppendHearder("Content-Disposition"........) remove it, it will be open in same window and will not give you any popup. Add all the content to Response.BinaryWrite(byte[],offset,count);

          S 1 Reply Last reply
          0
          • P Prateek G

            If you are using Response.AppendHearder("Content-Disposition"........) remove it, it will be open in same window and will not give you any popup. Add all the content to Response.BinaryWrite(byte[],offset,count);

            S Offline
            S Offline
            Sunil Wise
            wrote on last edited by
            #5

            Mr.Prateek G could u please tell me how to use Response.BinaryWrite method what are the values i have to give for the attributes byte, offset and count i have never used this Response.BinaryWrite method i am getting only the path and filename

            P 1 Reply Last reply
            0
            • S Sunil Wise

              its working in local system but if i try to open it in another system which is connected through lan again that filedownload window is opening sir

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              This is a sure sign that your overall design is broken, because it's working when your code can assume that the client is the server.

              Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

              1 Reply Last reply
              0
              • S Sunil Wise

                Mr.Prateek G could u please tell me how to use Response.BinaryWrite method what are the values i have to give for the attributes byte, offset and count i have never used this Response.BinaryWrite method i am getting only the path and filename

                P Offline
                P Offline
                Prateek G
                wrote on last edited by
                #7

                Try this string sourceFile = "C:\\Documents and Settings\\PrateekGupta\\Desktop\\pref.xml"; Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/octet-stream"; FileInputStream filIpStrm = null; MemoryStream ms = new MemoryStream(); filIpStrm = new FileInputStream(sourceFile); sbyte[] buffer = new sbyte[1024]; int len = 0; while ((len = filIpStrm.read(buffer)) >= 0) { byte[] bbuffer = new byte[1024]; System.Buffer.BlockCopy(buffer,0,bbuffer,0,1024); ms.Write(bbuffer,0,1024); } Response.OutputStream.Write(ms.ToArray(), 0, Convert.ToInt32(ms.Length)); filIpStrm.close(); Response.End(); let me know if it will work for u...

                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