Hello,
I'm trying to send a file from a local program (vb.net) to a webserver. I'm using the file on the website. But I keep having an error:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Net.ProtocolViolationException: Cannot send a content-body with this verb-type.
Here is the code I'm using:
Can somebody help me?
Thank you
I'm trying to send a file from a local program (vb.net) to a webserver. I'm using the file on the website. But I keep having an error:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Net.ProtocolViolationException: Cannot send a content-body with this verb-type.
Here is the code I'm using:
VB.NET:
Public Sub Upload()
Dim clsRequest As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("FTP file location"), System.Net.FtpWebRequest)
Dim bFile() As Byte = System.IO.File.ReadAllBytes("File location")
Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
Try
clsRequest.Credentials = New System.Net.NetworkCredential("Username", "Password") 'ftp username and password van de site
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
Catch ex As Exception
MessageBox.Show("Fault", "FOUTMELDING", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Can somebody help me?
Thank you