 |
|
Main Menu
|
|
|
Misc |
 |
|
Amazon |
 |
|
Links |
 |
|  |
| |
| Reading a
file using VB.net |
|
|
| |
|
| |
<%@ Import Namespace="System.IO" %>
<script language="vb" runat="server">
sub Page_Load(sender as Object, e as
EventArgs)
'Open the sampletext.txt file . Note
this is in the same directory as the
script
Dim testfile as String = Server.MapPath("sampletext.txt")
'Create a streamreader class
Dim objStreamReader as StreamReader
'open the file
objStreamReader = File.OpenText(testfile)
'Read the file storing it in the readfile
string
Dim readfile as String = objStreamReader.ReadToEnd()
'Place the string into a web control
lblTextFile.Text = readfile
'close the StreamReader class
objStreamReader.Close()
end sub
</script> <asp:label runat="server"
id="lblTextFile" />
|
|
|
| |
|
|
|
|
Software |
 |
| 
|