Converting from Byte Array

aroravicky

New member
Joined
Jun 23, 2004
Messages
2
Programming Experience
1-3
I have an byte array which i want to save as a particular document type for example .TXT. Can anybody help me out on the same.

Thanks in advance.

Vikas
 
here's a quick example i knocked together for you ...

VB.NET:
[size=2]

[/size][font=Courier New][size=2][color=#0000ff]Dim[/color][/size][size=2] strtext [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]String[/color][/size][/font][size=2][font=Courier New] = "some text"[/font]

[/size][font=Courier New][size=2][color=#0000ff]Dim[/color][/size][size=2] bytes [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]Byte[/color][/size][/font][size=2][font=Courier New]() = System.Text.Encoding.Default.GetBytes(strtext)[/font]

[/size][font=Courier New][size=2][color=#0000ff]Dim[/color][/size][size=2] fStream [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]New[/color][/size][/font][size=2][font=Courier New] IO.FileStream("C:\testing.txt", IO.FileMode.OpenOrCreate)[/font]

[/size][font=Courier New][size=2][color=#0000ff]Dim[/color][/size][size=2] sStream [/size][size=2][color=#0000ff]As[/color][/size][size=2] IO.Stream = [/size][size=2][color=#0000ff]DirectCast[/color][/size][/font][size=2][font=Courier New](fStream, IO.Stream)[/font]

[font=Courier New]sStream.Write(bytes, 0, bytes.Length)[/font]

[font=Courier New]MessageBox.Show("done")[/font]

[/size]

hope it helps :)
 
Back
Top