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 Operation Environment Windows 2000 Professional Version, .NET Framework SDK Test Second Edition (Beta 2)
two. The operation interface and operation results of this program are shown in the following figure:
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 objects used in the file - StreamReader defined in System.IO -StreamReader, this program is through this object to complete the file. Reading. Then it is displayed in text. As follows: Dim streamreaderobj As StreamReader file_name = filename.PostedFile.FileName 'reads out a specified file, and he assigned to the object streamreader Do filecont = streamreaderobj.ReadLine () Response.Write (filecont & "
") Loop Until FileCont = "" 'One line reads the contents of the file, knowing when reading a line of content is an empty string, stop streamreaderobj.close' After the read operation is complete, turn off the StreamReader object II> The form of the FORM used in the program should be Is "Multipart / Form-Data" without having to use his default encoding.
The specific use: