vb.net流,vbnet thread

vb.net 中,怎样获取内存中图片流的内存首地

你的意思是指序列化吧? .net里面有专门的序列化接口。百度下先……

专注于为中小企业提供网站建设、成都网站设计服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业建德免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了1000+企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

C#,VB.net,二进制流转回Word的时候能否知道他的文件名和后缀

无法直接获取,但可以采用变通的方法,思路:

把word转换成二进制流前先用变量把拓展名和后缀获取到(例如 var filename = “xxxx.doc”)

定义一个int变量记录二进制流(word)的长度。并将该变量转成4字节的btye[]数组

将第一步中获取到的文件名字符串转成byte[]数组。

将字节按照: word文件byte[]+文件名byte[]+word文件长度byte[](第二步)按照顺序拼接成一个byte[]数组

还原:

1.首先读取总byte[]的后4个字节,以确定文件二进制流的有效长度(假设为L).

2.将索引0至L 之间的字节数组按常规方式恢复成流.

3.将索引L至N-4之间的字节数组还原成字符串,即可获得原文件名.

然后,爱咋咋地~~~~

vb.net2005中提示无法在流的结尾之外进行读取

我给你一个实例,你自己修改;

一,运行界面:

二,完整代码:

Imports System.IO

Public Class Form1

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

'写文件

Dim Myw As New FileStream(Application.StartupPath "\实验文件.txt", FileMode.Create)

Dim MyB_Write As BinaryWriter = New BinaryWriter(Myw)

MyB_Write.Write(TextBox1.Text)

Myw.Close()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

'读文件

Dim Myr As New FileStream(Application.StartupPath "\实验文件.txt", FileMode.Open, FileAccess.Read)

Myr.Position = 0

Dim MyB_Read As New BinaryReader(Myr)

Dim MyFileLength As Integer = CInt(Myr.Length - Myr.Position) - 1

Dim MyFileData(MyFileLength) As Char

MyB_Read.Read(MyFileData, 0, MyFileLength)

Myr.Close()

TextBox2.Text = ""

Dim i As Integer

For i = LBound(MyFileData) To UBound(MyFileData)

TextBox2.Text = TextBox2.Text MyFileData(i)

Next

End Sub

End Class

vb.net读取文件流

dim filename as string = "文件名" Using myfilestream As New FileStream(FileName, FileMode.Open, FileAccess.Read)

Dim data() As Byte

ReDim data(myfilestream.Length - 1)

myfilestream.Read(data, 0, myfilestream.Length)

myfilestream.Close()

' data是你要的结果,为byte(), End Using


名称栏目:vb.net流,vbnet thread
浏览地址:http://scyanting.com/article/dscedeh.html