[VB] Write Byte Array to a text file

The following VB.NET program shows how to write the content of a Byte Array into a Text file.
Byte is an immutable value type that represents unsigned integers with values that range from 0 to 255 . Here we open a FileStream class instance and using the method Write() . Write() method writes a block of bytes to the current stream using data read from buffer.
oFileStream.Write(byteData, 0, byteData.Length)
FULL CODE :
Public Class Form1

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

		Dim str As String = "https://www.hungvb.com"
		Dim encod As New System.Text.UTF8Encoding
		Dim byteData() As Byte = encod.GetBytes(str)

		Dim oFileStream As System.IO.FileStream
		oFileStream = New System.IO.FileStream("c:\bytes.txt", System.IO.FileMode.Create)
		oFileStream.Write(byteData, 0, byteData.Length)
		oFileStream.Close()

	End Sub
End Class
Good luck.

1 تعليقات

✔ Bình luận có dấu, lịch sự và đúng chủ đề
❌ Không spam link, quảng cáo, từ ngữ phản cảm
❌ Không hỏi link tải, crack, nội dung vi phạm
⚠ Bình luận vi phạm sẽ bị xóa mà không báo trước

Thêm hình ảnh: [img] link hình ảnh [/img]
Thêm video youtube: [youtube] link video [/youtube]
Thêm code: [code] Đoạn code đã mã hóa [/code]

إرسال تعليق

✔ Bình luận có dấu, lịch sự và đúng chủ đề
❌ Không spam link, quảng cáo, từ ngữ phản cảm
❌ Không hỏi link tải, crack, nội dung vi phạm
⚠ Bình luận vi phạm sẽ bị xóa mà không báo trước

Thêm hình ảnh: [img] link hình ảnh [/img]
Thêm video youtube: [youtube] link video [/youtube]
Thêm code: [code] Đoạn code đã mã hóa [/code]

أحدث أقدم