A programming language, the size of the ability of file processing is often a manifestation of a language function. In ASP.NET, the processing of files is mainly implemented by a namespace in the .NET Framework SDK, which defines many of the file processing (Class), method for file processing, method in System.io namespace. And attributes, these classes, methods, and attributes make file processing in ASP.NET very much. Since there are many classes, methods, and attributes defined in this name space, these cannot be introduced one by one by this article. This paper mainly combines example to specifically describe basic operations for file processing.
The basic operation of the file is usually usually used. Specifically, reading, writing, copying, moving, deleting files. Let's take a specific introduction to these operations.
One. Program design and operating environment
Windows 2000 Professional Version, .NET Framework SDK Test Second Edition (Beta 2)
two. File read operation via the ASP.NET page
The running interface and operation results of this program are shown below:
Figure 1: Run interface of the program
Figure 2: Operation result interface of the program
1). Main ideas and steps in programming:
The programming used in this ASP.NET page is VB.NET. The main function of the program is to open the specified file and display the file as the ASCII code. Below is some of the main steps in programming:
I>. Read the object used in the file - StreamReader
Defining an object of a read file in System.IO, this program is to complete the reading of the file through this object. Then it is displayed in text. details as follows:
Dim StreamReaderobj As StreamReader
FILE_NAME = filename.postedfile.fileName
'Read a specified file and assign him to the StreamReader object
DO
FileCont = streamreaderobj.readline ()
Response.write (FileCont & "
)
Loop unsil filecont = "" "
'One line reads the contents of the file, know when reading a line of content is a niche,
StreamReaderobj.Close
'After reading the operation, turn off the StreamReader object.
II> The form of the FORM used in the program should be "multipart / form-data" without having to encode his default. details as follows: