default.aspx

来自「Code for VB.NET教程源码 很好的源码」· ASPX 代码 · 共 65 行

ASPX
65
字号
<%@ Page Trace="true" Language="VB" %>

<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.IO" %>

<H2>TextWriter</H2>

<script runat=server>

	Protected Sub WriteContentsToResponse( r As TextReader )
	
		Dim line As String

		line = r.ReadLine()

		While Not ( line Is Nothing )
		
			Response.Write(line)
			Response.Write( "<BR>" )
			line = r.ReadLine()
		End While

	End Sub

</script>


<%

Dim tw As TextWriter 

' Uncomment this to remove error (shows you can not create text writer class)
'tw = New TextWriter()



%>
<H3>Reading a String using TextReader</H3>
<P>The following lines are read from a string using StringReader :<BR><BR>

<%
	Dim text As String

	text = "A\nString\nContaining\nMultiple\nLines"
	WriteContentsToResponse( new StringReader(text))
%>

<H3>Reading a File using TextReader</H3>
<P>The following lines are reader from a file using File using StreamReader :<BR><BR>

<%
	Dim fileToRead As String
	Dim sr As StreamReader


	fileToRead = Server.MapPath("..\myfile.txt" )

	sr = File.OpenText( fileToRead )

	WriteContentsToResponse(sr)
	sr.Close()

%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?