PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 25 → Wx - Download de Arquivo via http (httprequest)
Wx - Download de Arquivo via http (httprequest)
Débuté par adrianoboller, 14 mar. 2016 00:11 - Aucune réponse
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 14 mars 2016 - 00:11
Prezados,

Segue codigo Enviado pelo Marcos Roberto de Gurupi - TO:

Procedure DownloadArq(fArq,fArqDestino)

OK is boolean

Retorno is string

OK = HTTPRequest(fArq)
IF OK = True THEN
Retorno = HTTPGetResult(httpResult)
ELSE
Info("Erro de endereco da pagina. "+fArq,ErrorInfo())
RESULT(False)
END

//Verifica se existe o arq

IF PositionOccurrence(Retorno,"Encontrada",firstRank,FromBeginning) = 0
IF OK = True THEN
Arquivo is Buffer = HTTPGetResult(httpResult)
IF InSimulatorMode() = True
IF fDirectoryExist(gpastapro) = False
OK = fMakeDir(gpastapro)
IF OK = False
Error("Não foi possivel criar o diretorio."+CR+ErrorInfo())
END
END
IF fFileExist(gpastapro+fArqDestino) THEN
fDelete(gpastapro+fArqDestino)
END
OK = fSaveBuffer(gpastapro+fArqDestino,Arquivo)
ELSE
IF fDirectoryExist(gpastapro) = False
OK = fMakeDir(gpastapro)
IF OK = False
Error("Não foi possivel criar o diretorio."+CR+ErrorInfo())
END
END
IF fFileExist(gpastapro+fArq) THEN
fDelete(gpastapro+fArq)
END
OK = fSaveBuffer(gpastapro+fArqDestino,Arquivo)
END
IF OK = True THEN
OK = fFileExist(gpastapro+fArqDestino)
IF OK = True THEN
HourGlass(False)
ToastDisplay("Download do arquivo "+fArqDestino+" efetuado com sucesso!",toastShort,vaMiddle,haCenter)
RESULT(True)
ELSE
HourGlass(False)
Error("Nao foi possivel encontrar o arquivo "+fArqDestino+" . "+ErrorInfo(errMessage))
RESULT(False)
END
ELSE
HourGlass(False)
Error("Nao foi possivel efetuar o download do "+fArqDestino+". "+ErrorInfo(errMessage))
RESULT(False)
END
ELSE
HourGlass(False)
Error("URL nao encontrado para download do "+fArqDestino+" "+ErrorInfo(errMessage))
RESULT(False)
END
ELSE
Info("Página não encontrada. ",fArq)
END
HourGlass(False)
RESULT(True)


Bons estudos!!!!

:merci:

--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.blogspot.com.br/