OVH Cloud OVH Cloud

traduction code Visual Basic

3 réponses
Avatar
MonicaVB
Bonjour/soir,
je voudrais retranscrire ce code JS en code VB
j'ai un peu de mal avec la connexion ftp
quelqu'un peut il m'aider
par avance merci

[code]var Now = new Date(new Number(new Date().valueOf() - (24 * 3600 *
1000))),
Day = Now.getDate(),
Month = Now.getMonth() + 1,
Year = Now.getYear(),
Client = "damart";

var Server = "192.168.1.124",
Username = "olivia",
Password = "0livi4",
Path = "",
LocalFilename = "G:\\awstats" + Client + ".txt";

var Filename = "awstats" + (Month < 10 ? "0" : "") + Month + Year + "." +
Client + ".txt";
var AspInet = new ActiveXObject("AspInet.ftp");
if (!AspInet.FTPGetFile(Server, Username, Password, Path + Filename,
LocalFilename, true, 2)) WScript.Echo("N'a pas réussi à charger : " +
Filename);;
AspInet = null;[/code]

Monica

3 réponses

Avatar
ng
Salut,

Ce code utilise des objets ASP (ASpInit) pour la connexion FTP.
Si tu as ces composants (c'est du COM) tu peux très bien aussi les utiliser
en VB, mais ce n'est pas une bonne solution (déploiement... licence...).

Il faudra donc procéder autrement : API Inet, controles OCX sur le net.

je voudrais retranscrire ce code JS en code VB
j'ai un peu de mal avec la connexion ftp
quelqu'un peut il m'aider
par avance merci

[code]var Now = new Date(new Number(new Date().valueOf() - (24 * 3600 *
1000))),
Day = Now.getDate(),
Month = Now.getMonth() + 1,
Year = Now.getYear(),
Client = "damart";

var Server = "192.168.1.124",
Username = "olivia",
Password = "0livi4",
Path = "",
LocalFilename = "G:awstats" + Client + ".txt";

var Filename = "awstats" + (Month < 10 ? "0" : "") + Month + Year + "." +
Client + ".txt";
var AspInet = new ActiveXObject("AspInet.ftp");
if (!AspInet.FTPGetFile(Server, Username, Password, Path + Filename,
LocalFilename, true, 2)) WScript.Echo("N'a pas réussi à charger : " +
Filename);;
AspInet = null;[/code]



--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
Avatar
Jacques93
Bonjour,
MonicaVB a écrit :
Bonjour/soir,
je voudrais retranscrire ce code JS en code VB
j'ai un peu de mal avec la connexion ftp
quelqu'un peut il m'aider
par avance merci

[code]var Now = new Date(new Number(new Date().valueOf() - (24 * 3600 *
1000))),
Day = Now.getDate(),
Month = Now.getMonth() + 1,
Year = Now.getYear(),
Client = "damart";

var Server = "192.168.1.124",
Username = "olivia",
Password = "0livi4",
Path = "",
LocalFilename = "G:awstats" + Client + ".txt";

var Filename = "awstats" + (Month < 10 ? "0" : "") + Month + Year + "." +
Client + ".txt";
var AspInet = new ActiveXObject("AspInet.ftp");
if (!AspInet.FTPGetFile(Server, Username, Password, Path + Filename,
LocalFilename, true, 2)) WScript.Echo("N'a pas réussi à charger : " +
Filename);;
AspInet = null;[/code]



Tu peux jeter un oeil sur le contrôle Microsoft Internet Transfer
Control (MSINET.OCX), ou comme l'indique NG passer par les APIS :

http://vbnet.mvps.org/index.html?code/internet/ftpdownload.htm

--
Cordialement,

Jacques.
Avatar
Gloops
Ah, c'est intéressant, ce que tu dis.

Pour résumer il faut se garder de trop shématiser.

A priori, entre JavaScript et VB, on aurait pu penser que le plus
indiqué pour attaquer des pages ASP c'était le plus spécifique à
Microsoft ... ben non, apparemment.