Subject: Sending a Memory Stream
Date: 2012-05-23 14:25:47
From: FRANK MEYERS
Source: sending-memory-stream
----------------------------------------------------------------------

Just wanted to share...

'Imports System.Text
'Imports System.IO
'Imports ComponentPro.Net
'Imports ComponentPro.IO

' Create a new instance.
Dim client As New Ftp()
Dim ms As New MemoryStream

Dim strText As String = "This is some sample text sentence that i am adding in this variable. I can also " & _
                        "get this variable from some other source like a file or a network socket or whatever"

' Encode the string to byte using UTF8
Dim enc As New UTF8Encoding
        Dim arrBytData() As Byte = enc.GetBytes(strText)
        ms.Write(arrBytData, 0, arrBytData.Length)

' Connect to the FTP server.
client.Connect("localhost")

' Authenticate.
client.Authenticate("test", "test")

' ...

'Find the beginning of byte array stored in memory
ms.Seek(0, SeekOrigin.Begin)


' Upload data from memory stream to '/test.dat'.
client.UploadFile(ms, "/test.dat", 0, -1)

' ...

' Disconnect, Close Stream, and Cleanup Memory.
ms.Close()
ms = Nothing
client.Disconnect()

----------------------------------------------------------------------

Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand
If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor
who sold you the license and ask for your money back.

Back to ComponentPro Q&A Forum Index