Bonjour à tous,

J'ai développé une application web qui doit uploader des fichiers vers un serveur Ftp.

Mais je n'arrive pas à uploader les fichiers.

Je passe par un fichier de commande Ftp : Ftp_Upload.bat :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
ftp -n -i -s:"C:\Essai_Ftp\ftp_cmd.txt">"C:\Essai_Ftp\ftp.log"
Le fichier ftp_cmd.txt :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
OPEN 100.100.100.100
user usr_essai
pwd_essai
binary
cd dir_essai
mput "C:\Essai_Ftp\*.doc"
quit
Voici le code C# qui appelle le fichier de commande :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
public void Envoi_Ftp()
        {
 
            Process oProc = new Process();
 
            ProcessStartInfo oInfo = new ProcessStartInfo();
 
            string sFtpCommandFile = "c:\\Essai_Ftp\\Ftp_Upload.bat";
            oInfo.FileName = sFtpCommandFile;
            oInfo.UseShellExecute = false;
            oInfo.WindowStyle = ProcessWindowStyle.Hidden;
 
            oProc.StartInfo = oInfo;
            oProc.Start();
            oProc.WaitForExit();
        }
Voici le fichier de log Ftp quand j'exécute ce code C# :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 
ftp> Connecté à 100.100.100.100
OPEN 100.100.100.100
220 ESSAI1
ftp> user usr_essai
331 User usr_essai, password please
 
230 Password Ok, User logged in
ftp> binary
200 Type Binary
ftp> cd dir_essai
250 Change directory ok
ftp> ftp> 
mput "C:\Essai_Ftp\*.doc"
200 Port command received
425 Unable to open the data connection
200 Port command received
425 Unable to open the data connection
200 Port command received
425 Unable to open the data connection
200 Port command received
425 Unable to open the data connection
ftp> ftp> 
quit
221
Par contre quand je lance manuellement le fichier de commande (Ftp_Upload.bat), les fichiers sont correctement uploadés.

Aussi, le code C# passe bien quand je désactive de Parefeu Windows (Windows 7).

Mais il faut que je laisse le Parefeu activé pour des raisons de sécurité.

Auriez-vous une idée ?

Merci beaucoup par avance.

Eric.