Examples of operating files in ASP.NET (VB)

zhaozj2021-02-16  52

An example (VB) of the file in ASP.NET Reposted: Andy.m Date: 2003-07-12 Popularity: 60 Example 1 in ASP.NET 1, write write writefile.aspx <% @ import namespace = " System.io "%>" introduces the desired Namespace <% response.write ("Writing the Content Into Text File In ASP.WRIT
) DIM STRWRITEROBJ AS StreamWriter 'declares a streamwriter object strwriterobj = file.createtext (" C: /ASPNET.TXT ") 'New text file, assign the value to the streamwriter object strwriterobj.writeline (Welcome to Wonderful World of Asp.Net Programming")' Write the content strwriterobj.close 'Close the object Response.write ( "DONE with the creation of text file and write content ing it")%> 2, read file readfile.aspx <% @ import namespace = "system.io"%> <% response.write ("Reading the Content from the text FILE ASPNET.TXT
") DIM StreamReaderobj AS StreamReader 'Declaration A streamReader object DIM FileCont AS String' declares a variable Save Read content streamReaderobj = file.opentext (" c: /ASPNET.TXT ") 'Open file assignment To streamReader object DO 'Press line loop read file content filecont = streamreaderobj.readline () Response.write (FileCont & "
") LOO p Until FileCont = "" streamreaderobj.close 'Close StreamReader object response.write ("
Done with lonning the content from the file aspnet.txt")%> 3, delete file filedelete.aspx <% @ import namespace = " System.io "%> <% file.delete (" c: /Aspnet.txt ") 'Delete file Response.write (" The File ASPNET IS DELETED SUCCESSFULLY !!! ")%>

转载请注明原文地址:https://www.9cbs.com/read-18491.html

New Post(0)