View Single Post
  #2 (permalink)  
Old 08-23-2008, 08:30 AM
dibesw dibesw is offline
Newbie
 
Join Date: Jul 2008
Posts: 8
Default

OK! ho scoperto come si fa.

la routine seguente esegue senza errori il download del file e lo salva in un LocalFile:
(ad es. URL=http://www.amalfiweb.it/webcam/img/webcam_00045.jpg)

Sub DownloadFile (LocalFile,URL)
ErrorLabel (errurl)
Response.New1
Request.New1(URL)
Response.Value = Request.GetResponse
Reader.New1(Response.GetStream,true)
FileOpen(c3,LocalFile,cRandom)
Writer.New1(c3,false)
Dim buffer(4096) As byte
count = Reader.ReadBytes(buffer(),4096)
Do While count > 0
Writer.WriteBytes2(buffer(),0,count)
count = Reader.ReadBytes(buffer(),4096)
Loop
FileClose(c3)
Response.Close
Return
errurl:
msgbox("Errore su load","Load immagine")
End Sub

Il problema è che se rieseguo la routine, per fare ad es. un refresh, il sistema mi da errore perchè il file (cioè l'immagine) risulta lockkata.

la routine seguente risolve questo caso perchè non esegue il salvataggio dell'immagine

Sub cercacam(URL)
ErrorLabel (errurl)
Request.New1(URL)
Response.New1
obj.New1(false)
args.New1(1)
Response.Value = Request.GetResponse
args.SetObject(0,Response.GetStream) '
obj.CreateNew2("System.Drawing.Bitmap" & obj.System_Drawing,args.Value)
image1.Image = obj.Value
response.Close
erore=0
Return
errurl:
erore=1
End Sub

le librerie sono HTTP e DOOR.

Spero sia stato utile a qualcuno.
Ciao
Reply With Quote