网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

vb点虐 io流的简单介绍

vb点虐 将文件转化成二进制

首先引入System.IO命名空间

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:空间域名、雅安服务器托管、营销软件、网站建设、沧源网站维护、网站推广。

Imports System.IO

然后使用文件流来读入数组:

Dim bytes() As Byte

Using fs As New FileStream(文件路径,FileMode.Open)

ReDim bytes(fs.Length-1)

fs.Read(bytes,0,fs.Length)

fs.Close()

End Using

这样bytes就是整个文件的所有字节了

从字节生成Image:

Dim img As Image = Image.FromStream(New MemoryStream(bytes))

img就是图片了

vb点虐 编程,修改和删除txt文档中的数据问题

为什么非要存成TXT文件呢?最好的办法是将你的这些数据存放在DataSet对象里,然后用DataSet对象的WriteXML方法写入文件。下次读取时,使用该对象的ReadXML方法就可以取回存在文件中的数据了。你想增、删、编辑都可以,很方便的!如果非要生成TXT文件,可以在DataSet对象顺序读取数据,然后再生成想要的TXT文件。你也用不着去追究IO流的操作了。

流关闭的问题!!!!(急)(VB.NET)

System.IO.StreamReader objread = new System.IO.StreamReader(path);

System.IO.Stream stream = objread.BaseStream;

objread.Close();

所有信息全在stream 里了

vb点虐 读取流

Imports System

Imports System.IO

Imports System.TextPublic Class Form2 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim path As String = "MyTest.txt" Try

If File.Exists(path) Then

File.Delete(path)

End If '写入流

Dim sw As StreamWriter = New StreamWriter(path)

sw.WriteLine("This")

sw.WriteLine("is some text")

sw.WriteLine("to test")

sw.WriteLine("Reading")

sw.Close()

'读取流

'Dim sr As StreamReader = New StreamReader(path) 'Do While sr.Peek() = 0

' 'This is an arbitrary size for this example.

' Dim c(5) As Char

' sr.Read(c, 0, c.Length)

' 'The output will look odd, because

' 'only five characters are read at a time.

' 'MsgBox(c)

'Loop

'sr.Close()

Catch ex As Exception

Console.WriteLine("The process failed: {0}", ex.ToString())

End Try End Sub '读取流

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

Dim path As String = "MyTest.txt" Dim reader As StreamReader = New StreamReader(path)

Dim c(5) As Char

reader.Read(c, 0, c.Length)

MsgBox(c)

reader.Close() End Sub

End Class 解读Read(arrayChar[]()[], Int32, Int32) buffer 类型:arraySystem..::.Char[]()[]

此方法返回时,包含指定的字符数组,该数组的 index 和 (index + count - 1) 之间的值由从当前源中读取的字符替换。 index 类型:System..::.Int32

开始写入的 buffer 的索引。 count 类型:System..::.Int32

最多读取的字符数。


网站题目:vb点虐 io流的简单介绍
分享地址:http://bjjierui.cn/article/ddicpse.html

其他资讯