programmingsite : code , tutorials and scripts
Navigation

home


ASP
ASP.net
C
C++
C#
PHP
Java
JavaScript
Powershell
VB.net

Visual Basic


Resources
code
tutorials
training

Ads
Products

 

 

Read a file using ASP.net




Read a file using ASP.net

This example shows how to read a file using ASP.net. Not that difficuly , concepts are the same as numerous other languages.


Code

<%@ 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" />



see this example here



Products
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals
Asp Studio 2005
Xtra PHP
Online PHP Script Encoder
Comparison

Links
Make money selling software
Uk shopping
UK price comparison
US price comparison
free articles
free stuff
Gambling resources
Software directory
XBox cheats and more
Sexy free wallpapers
Hosting resources
Nintendo Wii info
Beginners PHP
Health and fitness
Domain names
Dating site
Nintendo DS resources
Dropshippers
Maxi directory
Perfume and fragrances
PC shopping, tips and info
Magazine superstore

Ads