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

定制建站费用3500元

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

成都品牌网站建设

品牌网站建设费用6000元

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

成都商城网站建设

商城网站建设费用8000元

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

成都微信网站建设

手机微信网站建站3000元

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

建站知识

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

vb.net流读取文件 vbnet读写文件

vb.net读取文件流

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

成都创新互联专注于企业营销型网站建设、网站重做改版、张家口网站定制设计、自适应品牌网站建设、html5购物商城网站建设、集团公司官网建设、成都外贸网站建设公司、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为张家口等各大城市提供网站开发制作服务。

Dim data() As Byte

ReDim data(myfilestream.Length - 1)

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

myfilestream.Close()

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

vb.net中,读取和写入文件

写入:Dim sr As New IO.StreamWriter(Application.StartupPath "/写入的文本.txt")

sr.WriteLine("写入的内容") sr.Close()读取:If (File.Exists(Application.StartupPath "/msg.txt")) Then

Dim fm As New IO.FileStream(Application.StartupPath "/读取的文本.txt", FileMode.Open)

Dim sr As IO.StreamReader = New IO.StreamReader(fm)

Do While sr.Peek() = 0

TextBox1.Text = sr.ReadLine() (读取文本到文本框)

Loop end if

VB.net 读取文本文件

Imports System.IO

Public Class Form1

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

Dim sr As New StreamReader("d:\test.csv")

Dim arr1(), arr2(), arr3(), arr4() As Integer

Dim a1, a2, a3, a4 As New ArrayList

Do Until sr.EndOfStream

Dim str As String = sr.ReadLine

Dim s() As String = str.Split(",")

a1.Add(Convert.ToInt32(s(0)))

a2.Add(Convert.ToInt32(s(1)))

a3.Add(Convert.ToInt32(s(2)))

a4.Add(Convert.ToInt32(s(3)))

ListBox1.Items.Add(s(0))

Loop

arr1 = CType(a1.ToArray(GetType(Integer)), Integer())

arr2 = CType(a2.ToArray(GetType(Integer)), Integer())

arr3 = CType(a3.ToArray(GetType(Integer)), Integer())

arr4 = CType(a4.ToArray(GetType(Integer)), Integer())

sr.Close()

End Sub

End Class

VB.net 读取文本文件?

1、实现上传按钮方法代码。

2、判断图片对象是否为空代码。

3、取得数据库字段 dt.Rows(0)("Pic")方法代码。

4、字节数组转换为Image类型方法代码。

5、处理SQL中操作Image类型方法代码。

6、实现的上传结果。

VB.net窗体设计中,如何读取.txt文件中的数据?

1、新建一个标准的VB EXE工程,只有一个Form,Form上有两个按钮:Command1和Command2。

2、双击Command1添加如下代码

Private Sub Command1_Click()

Dim strFile     As String

Dim intFile     As Integer

Dim strData     As String

strFile = "c:\学生成绩.txt"

intFile = FreeFile

Open strFile For Input As intFile

strData = StrConv(InputB(FileLen(strFile), intFile), vbUnicode)

Debug.Print strData

Close intFile

End Sub

3、按F8开始单步调试代码,点击Command1,进入单步调试功能,

4、多次按下F8或直接按下F5运行完成,就完成了读取文本文件内容并输出到立即窗口。

vb.net 怎样读取文件

imports System.IO

读取指定文件

'

'读取指定文本文件

Public Function readtext(ByVal path As String)

If path = "" Then

readtext = "操作失败!"

Exit Function

End If

Try

If File.Exists(path) = True Then

Dim fs As New FileStream(path, FileMode.Open)

Dim sr As New StreamReader(fs)

Dim str As String

str = sr.ReadToEnd.ToString

sr.Close()

fs.Close()

readtext = str

Else

readtext = "操作失败!"

End If

Catch ex As Exception

readtext = "操作失败!"

End Try

End Function

'向指定文件写入数据

Public Function writetext(ByVal path As String, ByVal opi As Integer, ByVal msg As String)

If path = "" Then

writetext = "操作失败!"

Exit Function

End If

Dim op As FileMode

Select Case opi

Case 1

op = FileMode.Append

Case 2

op = FileMode.Create

Case Else

op = FileMode.Create

End Select

Try

If File.Exists(path) = True Then

Dim fs As New FileStream(path, op)

Dim sr As New StreamWriter(fs)

sr.WriteLine(msg)

sr.Close()

fs.Close()

writetext = "操作完成!"

Else

writetext = "操作失败!"

End If

Catch ex As Exception

writetext = "操作失败!"

End Try

End Function


网页名称:vb.net流读取文件 vbnet读写文件
网站地址:http://bjjierui.cn/article/hejjgh.html

其他资讯