首先文件的数据从数据库获得,然后要形成byte,返回客户端在生成txt文件。
请大家指教。

解决方案 »

  1.   

    直接在服务端生成TXT,然后返回给客户端TXT的链接地址
      

  2.   


     private void GetDocument()
            {
                SqlConnection cn = new SqlConnection(@"连接字符串");
                SqlDataReader dr = null;
                SqlCommand cm = new SqlCommand();
                cm.Connection = cn;
                cm.CommandType = CommandType.Text;
                cm.CommandText = "sql语句";
                cn.Open();
                dr = cm.ExecuteReader();
                byte[] File = null;
                if (dr.Read())
                {
                    File = (byte[])dr[0];
                }
                cn.Close();
                FileStream fs;
                FileInfo fi = new System.IO.FileInfo(@"c:\myfile.txt");
                fs = fi.OpenWrite();
                fs.Write(File, 0, File.Length);
                fs.Close();
            }
      

  3.   

    直接向客户端写byte感觉较好。同志们继续介绍下呢。
      

  4.   

    先在服务器端生成文件后以 FileStream 的方式向客户端写数据;应该就可以了。