vb.net的,c#也差不多:
http://www.zdnet.com.cn/developer/code/story/0,2000081534,39048920,00.htm

解决方案 »

  1.   

    http://study.mesky.net/infoview/Article_5564.html
      

  2.   

    用上传的方式:
    Stream imgDataStream = upFile.PostedFile.InputStream;
    int imgDataLen = upFile.PostedFile.ContentLength;
    byte[] imgDataTemp = new byte[imgDataLen];
    imgDataStream.Read( imgDataTemp, 0, imgDataLen );写回:
    Response.BinaryWrite( imgDataTemp );
    Response.End();
      

  3.   

    String strFileName = "c:\yourTxt.txt";//将文件用流读入到一个字符数组中
    FileStream f_stream;
    f_stream = new FileStream(strFileName, FileMode.Open);
    BinaryReader fReader = new BinaryReader(f_stream);FileInfo fi = new FileInfo(strFileName);
    int iReadCount = fi.Length;byte[] bBuffer = new byte[iReadCount];bBuffer = fReader.ReadBytes(iReadCount);
      

  4.   

    如果里面有中文,要指定Encoding否则乱码了。
    StreamReader MySRead=new StreamReader((System.IO.Stream)File.OpenRead("e:\\1.txt"),System.Text.Encoding.Default);
    string strHts=MySRead.ReadToEnd();
    Response.Write(strHts);
    MySRead.Close();
      

  5.   

    此问题已回过,要用gb2312,见
    http://expert.csdn.net/Expert/topic/2565/2565728.xml?temp=2.326602E-02
      

  6.   

    using System;
    using System.IO;class Test 
    {
        public static void Main() 
        {
            try 
            {
                // Create an instance of StreamReader to read from a file.
                // The using statement also closes the StreamReader.
                using (StreamReader sr = new StreamReader("TestFile.txt")) 
                {
                    String line;
                    // Read and display lines from the file until the end of 
                    // the file is reached.
                    while ((line = sr.ReadLine()) != null) 
                    {
                        Console.WriteLine(line);
                    }
                }
            }
            catch (Exception e) 
            {
                // Let the user know what went wrong.
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }
        }
    }