J
Jerry Spence1
I have the following code (copied from the web somewhere) which I am using
to upload some files:
Dim Filename As String = Dir(OutBox)
Do
Dim request As FtpWebRequest =
WebRequest.Create("ftp://<serverIP>/inbox/" & Filename)
request.Method = WebRequestMethods.Ftp.UploadFile
request.UseBinary = True
request.Credentials = New NetworkCredential("username",
"password")
Dim sourcestream As New StreamReader(OutBox & Filename)
Dim Filecontents As Byte()
Filecontents =
Encoding.UTF8.GetBytes(sourcestream.ReadToEnd())
sourcestream.Close()
request.ContentLength = Filecontents.Length
Dim requestStream = request.GetRequestStream()
requestStream.Write(Filecontents, 0, Filecontents.Length)
requestStream.Close()
Dim response = request.GetResponse()
response.Close()
File.Delete(OutBox & Filename)
Filename = Dir()
If Filename = "" Then Exit Do
Loop
I am copying jpg files so need a binary transfer. My problem is with the
encoding line. I don't want any encoding - I just want to copy the file as
it is. What should this line read?
Or, of course, is there a better way to do it?
-Jerry
to upload some files:
Dim Filename As String = Dir(OutBox)
Do
Dim request As FtpWebRequest =
WebRequest.Create("ftp://<serverIP>/inbox/" & Filename)
request.Method = WebRequestMethods.Ftp.UploadFile
request.UseBinary = True
request.Credentials = New NetworkCredential("username",
"password")
Dim sourcestream As New StreamReader(OutBox & Filename)
Dim Filecontents As Byte()
Filecontents =
Encoding.UTF8.GetBytes(sourcestream.ReadToEnd())
sourcestream.Close()
request.ContentLength = Filecontents.Length
Dim requestStream = request.GetRequestStream()
requestStream.Write(Filecontents, 0, Filecontents.Length)
requestStream.Close()
Dim response = request.GetResponse()
response.Close()
File.Delete(OutBox & Filename)
Filename = Dir()
If Filename = "" Then Exit Do
Loop
I am copying jpg files so need a binary transfer. My problem is with the
encoding line. I don't want any encoding - I just want to copy the file as
it is. What should this line read?
Or, of course, is there a better way to do it?
-Jerry