将text内容如何输出到文本文件中
我用datareader把一个数据表中内容显示在一个textbox中,现在想把textbox.text内容放到一个文本文件中,请问怎么实现?
还有就是我textbox里面把数据表字段的内容全部显示出来了,如何控制某一字段的记录数呢?
[此贴子已经被作者于2006-6-6 11:29:50编辑过]
Public Class Test
Public Shared Sub Main()
Dim path As String = "c:\temp\MyTest.txt"
If File.Exists(path) = False Then
' Create a file to write to.
Dim sw As StreamWriter = File.CreateText(path)
sw.WriteLine("Hello")
sw.WriteLine("And")
sw.WriteLine("Welcome")
sw.Flush()
sw.Close()
End If
' Open the file to read from.
Dim sr As StreamReader = File.OpenText(path)
Do While sr.Peek() >= 0
Console.WriteLine(sr.ReadLine())
Loop
sr.Close()
End Sub
End Class
看看这个例子就知道了