<%@ Import namespace= "System.IO"%> ' introduced the required Namespace
<%
Response.Write ("Writing the content into Text File in asp.net <BR>")
Dim Strwriterobj as StreamWriter ' declares a StreamWriter object
strwriterobj= file.createtext ("c:\aspnet.txt") ' Create a new text file, assign to StreamWriter object
Strwriterobj. WriteLine ("Welcome to wonderfull world of asp.net programming")
' Write content to a file
Strwriterobj. Close ' Closes the object
Response.Write ("Done with the creation of text file and writing content into it")
%>
2, read the file
Readfile.aspx
<%@ Import namespace= "System.IO"%>
<%
Response.Write ("Reading" the content from the text file ASPNET.) TXT <br> ")
Dim streamreaderobj as StreamReader ' declares a StreamReader object
Dim Filecont as String ' declares a variable to save read-out content
Streamreaderobj = File.OpenText ("c:\aspnet.txt") ' Open file assignment to StreamReader object
Do ' reads the contents of a file by line
Filecont = Streamreaderobj. ReadLine ()
Response.Write (Filecont & "<br>")
Loop Until Filecont = ""
Streamreaderobj. Close ' Closes the StreamReader object
Response.Write ("<br> done with reading the content from the file Aspnet.txt")
%>
3, delete the file
Filedelete.aspx
<%@ Import namespace= "System.IO"%>
<%
File.delete ("C:\aspnet.txt") ' Delete file
Response.Write ("The File ASPNET is deleted successfully!!!")
%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.