<%@ Page language="C #"autoeventwireup="true"%><! DOCTYPE HTML Public"-//W3C//DTD XHTML 1.0 transitional//en" "HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD"><script runat="Server">protected voidBtnupload_click (Objectsender, EventArgs e) { if(FileUpload1.PostedFile.InputStream.Length <1) {Msg.text="Please select a file. "; return; } stringFileName =Fileupload1.filename; if(Filename.tolower (). IndexOf (". txt") == -1) {Msg.text="Please select a text file. "; return; } intFileLen =FileUpload1.PostedFile.ContentLength; byte[] input =New byte[FileLen]; System.IO.Stream Uploadstream=FileUpload1.PostedFile.InputStream; Uploadstream.read (Input,0, FileLen); Uploadstream.position=0; System.IO.StreamReader SR=NewSystem.IO.StreamReader (Uploadstream, System.Text.Encoding.Default); Msg.text="the content of the file you uploaded is:<br/><br/>"+Sr. ReadToEnd (); Sr. Close (); Uploadstream.close (); Uploadstream=NULL; SR=NULL; }</script>"http://www.w3.org/1999/xhtml">"Server"> <title> Read the contents of the uploaded file directly without saving </title>"Mengxianhui"runat="Server"> <asp:fileupload id="FileUpload1"runat="Server"/> <asp:button id="Btnupload"runat="Server"text="Upload"onclick="Btnupload_click"></asp:Button> <p> <asp:label id="MSG"runat="Server"Forecolor="Red"></asp:Label></p> </form></body>Directly read the contents of the uploaded file without saving