Downloading a file

Hi!

Is there any way to download a file from http to the computer without using too much crazy activex?

System.Shell.Folder.copyHere("http:// ....") does not work. I need to download a picture, since there is no "Save picture as..." in gadget's context menu.

Thanks for any idea

[326 byte] By [miloush] at [2007-12-29]
# 1
Use an ADO binary stream to read it, then write the stream to a file. See this thread.
JonathanAbbott at 2007-9-4 > top of Msdn Tech,Gadgets,Sidebar Gadget Development...
# 2

Thanks, that seems suitable.

It would be much easier if I could get the Shell.Item object for the URI, though (if you look for suggestions for future versions )

miloush at 2007-9-4 > top of Msdn Tech,Gadgets,Sidebar Gadget Development...
# 3

Hi again...

I cannot make it working... how should I load the file? If I use stream.Open("http...") I get argument error and if I use stram.LoadFromFile("http...") I get file could not be opened...

miloush at 2007-9-4 > top of Msdn Tech,Gadgets,Sidebar Gadget Development...
# 4
On second thoughts, that's not going to work. You'll need to read the image via an XML request, but that has a limit on the amount of data you can read, so that will probably fail too:

var xmlReq;

function loadImage(url) {

xmlReq = new XMLHttpRequest();
xmlReq.onreadystatechange = imageCheck;
xmlReq.open("GET", url, true);
xmlReq.send(null);
}

function imageCheck() {
if(xmlReq.readyState < 4) return;

if(xmlReq.status == 200) {
// image may be in xmlReq.responseText;
}

xmlReq.abort();
}

ActiveX is probably going to be your only solution, unfortunately.

JonathanAbbott at 2007-9-4 > top of Msdn Tech,Gadgets,Sidebar Gadget Development...
# 5

Things are getting complicated a bit...but okay, I'll try. Do you have any idea what the limit is?

However, since I don't expect the file to exceed 100kB I guess it should work well.

miloush at 2007-9-4 > top of Msdn Tech,Gadgets,Sidebar Gadget Development...