Notifications
Clear all

[Closed] How to write a string to stream?

Hi guys,
It’s a very simple question,I know how to convert stream to string,but I want to write a string to stream,how can I do that?

--Read stream ,I can do this 
streamReader=DotNetObject "System.Byte[]" 8192
--Someway to Receive streamReader
Encoding=DotnetClass  "System.Text.Encoding"
Receive_txt=Encoding.UTF8.GetString(streamReader)

--Write stream,how can I do this ?
streamWriter=DotNetObject "System.Byte[]" 8192
theString="The string to be write"
--Someway to Send streamWriter
2 Replies
byte_array = (dotnetclass "System.Text.Encoding").UTF8.GetBytes "Hello, World!" asdotnetobject:on
the_string = (dotnetclass "System.Text.Encoding").UTF8.GetString byte_array 0 byte_array.Length

Thanks for help,I did it with this code:

		streamWriter=DotNetObject "System.Byte[]" 8192	
		sendText="Hello,world"
		Encoding=DotnetClass "System.Text.Encoding"
		need_Send_txt=Encoding.UTF8.GetBytes(sendText)
        --Someway to Send need_Send_txt