553 (Nom de fichier non autorisé) Transfert

Messages postés
388
Date d'inscription
mardi 1 juillet 2003
Statut
Membre
Dernière intervention
18 novembre 2019
-
Bonjour, j'ai l'erreur 553 (Nom de fichier non autorisé) sur :
Using requestStream As Stream = request.GetRequestStream()

J'ai ajouté la ligne car je pensais que cela venait de la sécurité.
System.Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls12

Merci pour votre aide.
Imports System
Imports System.IO
Imports System.Net
Imports System.Text

Module Module1
    Public Sub Main()
        System.Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls12
        Dim request As FtpWebRequest = CType(WebRequest.Create("ftp://00.000.00.00/httpdocs/Cloud"), FtpWebRequest)
        request.Method = WebRequestMethods.Ftp.UploadFile
        request.Credentials = New NetworkCredential("...", "...")
        Dim fileContents As Byte()

        If IO.File.Exists(Application.StartupPath & "\testfile.txt") = False Then
            MsgBox("Erreur")
        End If
        Using sourceStream As StreamReader = New StreamReader(Application.StartupPath & "\testfile.txt")
            fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd())
        End Using

        request.ContentLength = fileContents.Length

        Using requestStream As Stream = request.GetRequestStream() 'Erreur 553
            requestStream.Write(fileContents, 0, fileContents.Length)
        End Using

        Using response As FtpWebResponse = CType(request.GetResponse(), FtpWebResponse)
            Console.WriteLine($"Upload File Complete, status {response.StatusDescription}")
        End Using
    End Sub
End Module
Afficher la suite