Use the STREAMWRITER, StreamReader, and File classes in System.io name, complete file read, write, and delete.
-------------------------------------------------- ------------------------------
1, write files
Writefile.aspx
<% @ Import namespace = "system.io"%> "introduced the required namespace
<%
Response.write ("Writing The Content Into Text File in Asp.Net
)
DIM STRWRITEROBJ AS streamwriter 'declares a streamwriter object
Strwriterobj = file.createtext ("C: /ASPNET.TXT") 'New text file, assign a value to the streamwriter object
Strwriterobj.writeline ("Welcome to Wonderful World of Asp.Net Programming")
'Write content to your file
Strwriterobj.close 'Close Object
Response.write ("Done with the creation of text file and write content ing it")
%>
2, read the file
Readfile.aspx
<% @ Import namespace = "system.io"%>
<%
Response.write ("Reading The Content from the Text File ASPNET.TXT
")
Dim StreamReaderobj As StreamReader 'declares a streamreader object
Dim filecont as string 'declares a variable to save the read content
StreamReaderobj = file.opentext ("c: /Aspnet.txt") 'Opens file assignment to StreamReader object
Do 'read file content by row
FileCont = streamreaderobj.readline ()
Response.write (FileCont & "
")
Loop unsil filecont = "" "
StreamReaderobj.close 'Close StreamReader object
Response.write (""
Done with reading the content from the file aspnet.txt ")
%>
3, delete files
FILEDELETE.ASPX
<% @ Import namespace = "system.io"%>
<%
File.delete ("c: /Aspnet.txt") 'Delete file
Response.write ("The File ASPNET IS DELETED SUCCESSFULLY !!!")
%>