5 Replies - 332 Views - Last Post: 30 December 2019 - 07:27 AM Rate Topic: -----

#1 brol0001   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 27-November 12

FtpWebRequest file upload and download fails after KB4517389 update

Posted 28 December 2019 - 04:21 AM

After the Windows KB4517389 which came with windows version 1903 this code cannot download or upload files anymore.
I use framework 4.6, 4.7 and 4.8.
The exception is thrown after te filestream gets closed.
 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
     UploadFile("test.txt", Server & "/test.txt", User, PW)
  End Sub
  
  Public Sub UploadFile(ByVal _FileName As String, ByVal _UploadPath As String, ByVal _FTPUser As String, ByVal _FTPPass As String)
    Try
      Dim _FileInfo As New System.IO.FileInfo(_FileName)
      Dim _FtpWebRequest As System.Net.FtpWebRequest = CType(System.Net.FtpWebRequest.Create(New Uri(_UploadPath)), System.Net.FtpWebRequest)          
          _FtpWebRequest.Credentials = New System.Net.NetworkCredential(_FTPUser, _FTPPass)
          _FtpWebRequest.EnableSsl = True
          _FtpWebRequest.KeepAlive = False
          _FtpWebRequest.Timeout = 15000
          _FtpWebRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
          _FtpWebRequest.UseBinary = True
          _FtpWebRequest.ContentLength = _FileInfo.Length
             Dim buffLength As Integer = 2048
            Dim buff(buffLength) As Byte
            Dim _FileStream As System.IO.FileStream = _FileInfo.OpenRead()
            Dim _Stream As System.IO.Stream = _FtpWebRequest.GetRequestStream()
            Dim contentLen As Integer = _FileStream.Read(buff, 0, buffLength)
            Do While contentLen <> 0
            _Stream.Write(buff, 0, contentLen)
            contentLen = _FileStream.Read(buff, 0, buffLength)
            Loop
            _Stream.Close()
            _Stream.Dispose()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
  End Sub


This post has been edited by modi123_1: 28 December 2019 - 10:59 AM
Reason for edit:: In the future please use the [code] tag button in the editor


Is This A Good Question/Topic? 0
  • +

Replies To: FtpWebRequest file upload and download fails after KB4517389 update

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15477
  • View blog
  • Posts: 62,007
  • Joined: 12-June 08

Re: FtpWebRequest file upload and download fails after KB4517389 update

Posted 28 December 2019 - 10:59 AM

Please copy/paste the full exception text.
Was This Post Helpful? 0
  • +
  • -

#3 brol0001   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 27-November 12

Re: FtpWebRequest file upload and download fails after KB4517389 update

Posted 28 December 2019 - 11:11 AM

The exception says The underlaying connection is closed. The server caused an error in the protocol.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15477
  • View blog
  • Posts: 62,007
  • Joined: 12-June 08

Re: FtpWebRequest file upload and download fails after KB4517389 update

Posted 28 December 2019 - 11:20 AM

Is there a .innerexception message?
Was This Post Helpful? 0
  • +
  • -

#5 brol0001   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 27-November 12

Re: FtpWebRequest file upload and download fails after KB4517389 update

Posted 28 December 2019 - 11:39 AM

The innerexception is the name of the executable file.

The connection must be made because an empty file is left on the server.

Tried to opload a file using Total Commander, same problem.
Tried WINSCP... this program does the job as wel with and without the KB4517389 opdate installed.
Was This Post Helpful? 0
  • +
  • -

#6 brol0001   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 27-November 12

Re: FtpWebRequest file upload and download fails after KB4517389 update

Posted 30 December 2019 - 07:27 AM

Still don't know why the code is not working while it must be possible to get it working.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1