Aide visual basic 2008

Résolu/Fermé
zitoune-anticip Messages postés 15 Date d'inscription mardi 29 mars 2011 Statut Membre Dernière intervention 30 mars 2011 - 30 mars 2011 à 03:19
Patrice33740 Messages postés 8556 Date d'inscription dimanche 13 juin 2010 Statut Membre Dernière intervention 2 mars 2023 - 30 mars 2011 à 23:38
Bonjour,

j'ai créer une application permettant un partage de fichier via FTP.
que ce soit upload ou download tout fonctionne à merveille (tester sur xp & vista).
Cependant , pour des mesures de sécurité pour moi j'ai intégrer un code me permettant de voir qui utilise et quand cette application est utilisé. (cela évite qu'on face tourner mon application et que je soit obliger de chercher via les ips dans mon Server ftp).
Mon problème étant que pour chaque utilisateur un fichier login se créera et sera automatiquement envoyer sur mon Server voici le code :



Private Sub FrmPrincipal_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
Dim FSys 
FSys = CreateObject("Scripting.FileSystemObject") 
Dim Comand 
Comand = FSys.CreateTextFile("C:\ftp\script\ftp.txt") 'fichier créer 
With Comand 'ecris les commandes 
Comand.writeLine("open @ftp") 
Comand.writeLine("id") 
Comand.writeLine("mdp") 
Comand.writeLine("put C:\ftp\script\login.txt") 
Comand.writeLine("quit") 
End With 
Comand.Close() 
'*********************** 
'declaration 
Dim shell, Info, Computer, Nam, Dat, Tim, Fin, Ftp 
shell = CreateObject("WScript.Shell") 
'ecriture 
Info = "cmd /c echo **************************>>c:\ftp\script\login.txt" 
Computer = "cmd /c echo pc: %computername%>>c:\ftp\script\login.txt" 
Nam = "cmd /c echo user: %username%>>c:\ftp\script\login.txt" 
Dat = "cmd /c echo date: %date%>>c:\ftp\script\login.txt" 
Tim = "cmd /c echo heure: %time%>>c:\ftp\script\login.txt" 
Fin = "cmd /c echo **************************>>c:\ftp\script\login.txt" 
Ftp = "cmd /c ftp -s:c:\ftp\script\ftp.txt" 
'lancement 
shell.Run(Info, 0, True) 
shell.Run(Computer, 0, True) 
shell.Run(Nam, 0, True) 
shell.Run(Dat, 0, True) 
shell.Run(Tim, 0, True) 
shell.Run(Fin, 0, True) 
shell.Run(Ftp, 0, True) 
Dim Result 
Result = shell.Run(Ftp, 0, True) 
'supression 
If System.IO.File.Exists("c:\ftp\script\login.txt") Then 
File.Delete("c:\ftp\script\login.txt") 
End If 
If System.IO.File.Exists("c:\ftp\script\ftp.txt") Then 
File.Delete("c:\ftp\script\ftp.txt") 
End If 
'****************************************************************** 
'fin rapport 
End Sub



le problème est que le fichier uploader aura toujours le même nom que celui qui se trouve sur le Server.
j'ai pensée à la solution de nommé le fichier à uploader en %date% ou %time% mais cela comporte des caractères interdit pour nommé un fichier.
le nommé en %username% reviendrai à avoir toujours le même nom du fichier à uploader à celui se trouvant sur le server !!
je cogite, cogite mais en vain pour l'instant quelqu'un aurai-t-il une idées à mon problème ?


PS: si vous avez besoin plus d'info voir ci-joint
https://www.youtube.com/watch?v=FYHSnvHfrxY


Vous remerciant du temps accorder à ma demande
A voir également:

2 réponses

zitoune-anticip Messages postés 15 Date d'inscription mardi 29 mars 2011 Statut Membre Dernière intervention 30 mars 2011
30 mars 2011 à 23:24
voilà la réponse à ma question été dans mon post :-)
il s'agissait simplement de laisser du temps au commande c'est pourquoi j'ai séparer mon besoin en deux form déjà présente
code :
Option Explicit On
Option Strict Off
Imports System.IO
Public Class FrmLogin
    
    Private Sub FrmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MsgBox("Bonjour, vous allez être invité à saisir vos identifiants. Les utilisateurs n'ayant pas eu d'identifiant devront saisir dans MDP : <anonyme>. Mais n'auront pas accès à l'intégralité du logiciel , vous pouvez toujours me faire parvenir une demande à l'adresse suivante : <@> ", vbInformation, "Z!T¤ùn€ @NT!C!P-W!N-32")
        Dim FSys
        FSys = CreateObject("Scripting.FileSystemObject")
        Dim shell, envoi
        shell = CreateObject("WScript.Shell")
        '*****************************************************************************
        '*****************************************************************************
        Dim Comande
        Comande = FSys.CreateTextFile("C:\ftp\script\envoi.txt") 
        With Comande 
            Comande.writeLine("open @ftp")
            Comande.writeLine("id")
            Comande.writeLine("mdp")
            Comande.writeLine("lcd c:\ftp\script")
            Comande.writeLine("get login.txt")
            Comande.writeLine("quit")
        End With
        Comande.Close()
        '*****************************************************************************
        '*****************************************************************************
        envoi = "cmd /c ftp -s:c:\ftp\script\envoi.txt"
        shell.Run(envoi, 0, True)
        Dim Recup
        Recup = shell.Run(envoi, 0, True)
    End Sub

et
Option Explicit On

Option Strict Off
Imports System.IO

Public Class FrmPrincipal

Private Sub FrmPrincipal_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.MonWeb.Navigate("http://@site")
'*****************************************************************************
'*****************************************************************************
'envoie rapports des connexion
Dim FSys
FSys = CreateObject("Scripting.FileSystemObject")
Dim shell, Info, Computer, Nam, Dat, Tim, Fin, Ftp
shell = CreateObject("WScript.Shell")
'*****************************************************************************
'*****************************************************************************
Info = "cmd /c echo **************************>>c:\ftp\script\login.txt"
Computer = "cmd /c echo pc: %computername%>>c:\ftp\script\login.txt"
Nam = "cmd /c echo user: %username%>>c:\ftp\script\login.txt"
Dat = "cmd /c echo date: %date%>>c:\ftp\script\login.txt"
Tim = "cmd /c echo heure: %time%>>c:\ftp\script\login.txt"
Fin = "cmd /c echo **************************>>c:\ftp\script\login.txt"
'*****************************************************************************
shell.Run(Info, 0, True)
shell.Run(Computer, 0, True)
shell.Run(Nam, 0, True)
shell.Run(Dat, 0, True)
shell.Run(Tim, 0, True)
shell.Run(Fin, 0, True)
'*****************************************************************************
'*****************************************************************************
Dim Comand
Comand = FSys.CreateTextFile("C:\ftp\script\ftp.txt")
With Comand
Comand.writeLine("open @ftp")
Comand.writeLine("id")
Comand.writeLine("mdp")
Comand.writeLine("put C:\ftp\script\login.txt")
Comand.writeLine("quit")
End With
Comand.Close()
'*****************************************************************************
Ftp = "cmd /c ftp -s:c:\ftp\script\ftp.txt"
shell.Run(Ftp, 0, True)
Dim uplo
uplo = shell.Run(Ftp, 0, True)
'*****************************************************************************
'*****************************************************************************
MsgBox("Pensé à vérifier les mise à jour")
'*****************************************************************************
If System.IO.File.Exists("c:\ftp\script\envoi.txt") Then
File.Delete("c:\ftp\script\envoi.txt")
End If
If System.IO.File.Exists("c:\ftp\script\login.txt") Then
File.Delete("c:\ftp\script\login.txt")
End If
If System.IO.File.Exists("c:\ftp\script\ftp.txt") Then
File.Delete("c:\ftp\script\ftp.txt")
End If
'******************************************************************
'fin rapport
End Sub
0
Patrice33740 Messages postés 8556 Date d'inscription dimanche 13 juin 2010 Statut Membre Dernière intervention 2 mars 2023 1 775
30 mars 2011 à 23:38
Peux-tu passer ton post en résolu ?
0