Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
499 views
in Technique[技术] by (71.8m points)

ftp - FTPWebRequest in VB.net not working all the time

I'm having this problem, I'm trying to upload a file to FTP site, the code is:

 reqFTP = DirectCast(FtpWebRequest.Create(New Uri(URI & tmpDirFile)), FtpWebRequest)
        reqFTP.Method = WebRequestMethods.Ftp.UploadFile
        reqFTP.UseBinary = True
        reqFTP.KeepAlive = False
        reqFTP.UsePassive = True

        reqFTP.Credentials = New NetworkCredential(UserID, Pwd)
        reqFTP.ContentLength = fileContents.Length
        ftpStream = reqFTP.GetRequestStream()

        ftpStream.Write(fileContents, 0, fileContents.Length)

        ftpStream.Flush()
        ftpStream.Close()

the issue is that the code is working but not always, the setting of the server does not change (it is a basic FTP server without username and password), so I don't understand what it is happening, I hope somebody get this problem and found the solution

The error return is: The remote server returned an error: (425) Can't open data connection.

question from:https://stackoverflow.com/questions/65946255/ftpwebrequest-in-vb-net-not-working-all-the-time

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...