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. General Programming
  3. C#
  4. UrlDownloadToFile strange behaviour

UrlDownloadToFile strange behaviour

Scheduled Pinned Locked Moved C#
htmlcomdebugginghelp
5 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.
  • G Offline
    G Offline
    GriffonRL
    wrote on last edited by
    #1

    Hello, I have come across a strange behaviour. I typed the following code: [DllImport("urlmon.dll",CharSet=CharSet.Auto)] public static extern uint URLDownloadToFile( IntPtr pCaller, string szURL, string szFileName, uint dwReserved, IntPtr lpfnCB); string URL="http://www.boursorama.com"; URLDownloadToFile(IntPtr.Zero,URL,"c:\test.html",0,IntPtr.Zero); When I run it (using the debugger), the function doesn't seems to send back an error and the function seems actually to work but I get no local file ! I even looked at the HTTP requests and I can see the HTTP GET issued and the 200 OK response. I don't understand and I need UrlDownloadToFile (WebClient doesn't work with the IE cache). I'm using the 1.1 framework on Windows 2000 Professionnal. Thanks, R. LOPES Just programmer.

    J 1 Reply Last reply
    0
    • G GriffonRL

      Hello, I have come across a strange behaviour. I typed the following code: [DllImport("urlmon.dll",CharSet=CharSet.Auto)] public static extern uint URLDownloadToFile( IntPtr pCaller, string szURL, string szFileName, uint dwReserved, IntPtr lpfnCB); string URL="http://www.boursorama.com"; URLDownloadToFile(IntPtr.Zero,URL,"c:\test.html",0,IntPtr.Zero); When I run it (using the debugger), the function doesn't seems to send back an error and the function seems actually to work but I get no local file ! I even looked at the HTTP requests and I can see the HTTP GET issued and the 200 OK response. I don't understand and I need UrlDownloadToFile (WebClient doesn't work with the IE cache). I'm using the 1.1 framework on Windows 2000 Professionnal. Thanks, R. LOPES Just programmer.

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      GriffonRL wrote: "c:\test.html" Have you tried "c:\\test.html"? The double backslash is needed to escape the \, other wise you wind up with \t which is the tab character. James "I despise the city and much prefer being where a traffic jam means a line-up at McDonald's" Me when telling a friend why I wouldn't want to live with him

      J G 2 Replies Last reply
      0
      • J James T Johnson

        GriffonRL wrote: "c:\test.html" Have you tried "c:\\test.html"? The double backslash is needed to escape the \, other wise you wind up with \t which is the tab character. James "I despise the city and much prefer being where a traffic jam means a line-up at McDonald's" Me when telling a friend why I wouldn't want to live with him

        J Offline
        J Offline
        J Dunlap
        wrote on last edited by
        #3

        try @"c:\test.html" instead. The @ character means a string literal with no escape sequences.

        "Do unto others as you would have them do unto you." - Jesus
        "An eye for an eye only makes the whole world blind." - Mahatma Gandhi

        G 1 Reply Last reply
        0
        • J J Dunlap

          try @"c:\test.html" instead. The @ character means a string literal with no escape sequences.

          "Do unto others as you would have them do unto you." - Jesus
          "An eye for an eye only makes the whole world blind." - Mahatma Gandhi

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

          Hello, Thanks for answering but look at that: URLDownloadToFile(IntPtr.Zero,"http://www.kimo.com.tw",@"c:\test1.htm",0,IntPtr.Zero); <-- create the file URLDownloadToFile(IntPtr.Zero,"http://www.yahoo.com",@"c:\test2.htm",0,IntPtr.Zero); <-- create the file URLDownloadToFile(IntPtr.Zero,"http://www.boursorama.com",@"c:\test3.htm",0,IntPtr.Zero); <-- doesn't create the file Any idea ? Try by yourself. R. LOPES Just programmer.

          1 Reply Last reply
          0
          • J James T Johnson

            GriffonRL wrote: "c:\test.html" Have you tried "c:\\test.html"? The double backslash is needed to escape the \, other wise you wind up with \t which is the tab character. James "I despise the city and much prefer being where a traffic jam means a line-up at McDonald's" Me when telling a friend why I wouldn't want to live with him

            G Offline
            G Offline
            GriffonRL
            wrote on last edited by
            #5

            Hello, Thanks for answering but look at that: URLDownloadToFile(IntPtr.Zero,"http://www.kimo.com.tw",@"c:\test1.htm",0,IntPtr.Zero); <-- create the file URLDownloadToFile(IntPtr.Zero,"http://www.yahoo.com",@"c:\test2.htm",0,IntPtr.Zero); <-- create the file URLDownloadToFile(IntPtr.Zero,"http://www.boursorama.com",@"c:\test3.htm",0,IntPtr.Zero); <-- doesn't create the file Any idea ? Try by yourself. R. LOPES Just programmer.

            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