27/08/2021

[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 nhận xét:

#Catalogics

AMP (3) ANTIVIRUS (1) ASP.NET (1) BLOGGER (29) C# (19) Cam-Xuc (1) CHROME (4) CSHARP (2) CSS (7) DOMAIN (2) DOWNLOAD (41) EVN (3) FACEBOOK (4) FEELING (19) FSHARE (1) GOOGLE (6) HTML (12) IMAGE (2) INFOGRAPHIC (3) JAVASCRIPT (13) Manus_JS (1) Microsoft (4) NetCat (1) NOTIFICATION (8) PDF (1) Php (3) PROGRAM (10) SECURITY (2) SELEMIUM (1) SEO (11) Software (9) Tips (44) Visual Basic (57) WINDOWS (24) WordPress (3) YOUTUBE (3)

Total View Pages