vb.nettxt操作的简单介绍( 二 )


4、字节数组转换为Image类型方法代码 。
5、处理SQL中操作Image类型方法代码 。
6、实现vb.nettxt操作的上传结果 。
怎样用vb.net读取本地.txt文件?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源代码来自
'
【vb.nettxt操作的简单介绍】vb.nettxt操作的介绍就聊到这里吧,感谢你花时间阅读本站内容 , 更多关于、vb.nettxt操作的信息别忘了在本站进行查找喔 。

推荐阅读