UrlDownloadToFile strange behaviour
-
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. -
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.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
-
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
-
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 GandhiHello, 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.
-
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
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.