if (fu.PostedFile.InputStream.Length < 1) { Comm.MessageBox.Show("请选择文件"); } string FileName = fu.FileName;//上传文件文件名 string FilePath = fu.PostedFile.FileName;//上传文件完整路径+文件名 if (FileName.ToLower().IndexOf(".txt") == -1) { Comm.MessageBox.Show("请选择要求的类型的文件"); } int FileLen = fu.PostedFile.ContentLength;//获取上传文件的大小 byte[] input = new byte[FileLen]; System.IO.Stream UpLoadStream = fu.PostedFile.InputStream; UpLoadStream.Read(input, 0, FileLen); UpLoadStream.Position = 0; System.IO.StreamReader sr = new System.IO.StreamReader(UpLoadStream, System.Text.Encoding.Default); string aa = sr.ReadToEnd(); sr.Close(); UpLoadStream.Close(); UpLoadStream = null; sr = null;