Dec
16
vb.net 创建与读取文本文件的方法
雪糕先生 2010/12/16 13:24
下面是创建代码:
If File.Exists("C:\abc.txt") Then
File.Delete("C:\abc.txt")
End If
Dim sr As StreamWriter = File.CreateText("C:\abc.txt")
sr.Write("晨彦电脑科技")
sr.WriteLine("WWW.BTOSS.COM")
sr.Write("这是一个创建文本文件的例子")
sr.Close()
下面是读取代码:
If File.Exists("C:\abc.txt") = False Then
MsgBox("文件不存在!")
Else
Dim sr As StreamReader = File.OpenText("C:\abc.txt")
Dim str As String = sr.ReadLine
Dim i As Integer = 0
While Not IsNothing(str)
i = i + 1
If i = 1 Then
Me.TextBox1.Text &= str
Else
Me.TextBox1.Text &= "," + str
End If
str = sr.ReadLine
End While
End If
引用
If File.Exists("C:\abc.txt") Then
File.Delete("C:\abc.txt")
End If
Dim sr As StreamWriter = File.CreateText("C:\abc.txt")
sr.Write("晨彦电脑科技")
sr.WriteLine("WWW.BTOSS.COM")
sr.Write("这是一个创建文本文件的例子")
sr.Close()
下面是读取代码:
引用
If File.Exists("C:\abc.txt") = False Then
MsgBox("文件不存在!")
Else
Dim sr As StreamReader = File.OpenText("C:\abc.txt")
Dim str As String = sr.ReadLine
Dim i As Integer = 0
While Not IsNothing(str)
i = i + 1
If i = 1 Then
Me.TextBox1.Text &= str
Else
Me.TextBox1.Text &= "," + str
End If
str = sr.ReadLine
End While
End If
品质教程
2010/12/25 09:23
学习了,真给力!
软件资讯
2010/12/22 20:55
VB学习抽象不?
雪糕先生 回复于 2010/12/23 10:36
VB是最简单的语言了
软件资讯
2010/12/22 20:55
VB学习抽象不?
duguyue100
2010/12/16 15:56
东西看懂了,但弱弱的问一句,想干啥??饿~貌似是文件读取。。哦。。恍然大悟。。
分页: 1/1 1
分类
热门文章
- [45698]五种方法安装Windows...
- [29076]您可能需要与该网络的 in...
- [14238]开机自动检测网络状态运行程...
- [14122]2012东埔英歌舞
- [12570]APMServ一键快速搭建...
- [12547]双路由器上网的连接和设置方...
- [12479]Google提供的免费天气...
- [12407]各种BIOS的设置细解
- [12388]EvaPhone - 无需...
- [12120]雪糕乐园小游戏集2.04版...