把Stream 保存到客户端


                //读取下载的文件流
                if (fileStream.CanRead)
                {
                    int length;
                    byte[] buffer = new byte[10000];
                    length = fileStream.Read(buffer, 0, 10000);
                    long dataToRead = fileLength;
                    if (!Directory.Exists(@"c:\downFile"))
                    {
                        Directory.CreateDirectory(@"c:\downFile");
                    }
                    FileStream fstr = new FileStream(@"c:\downFile\" + _FileName, FileMode.Create, FileAccess.Write);

                    fstr.Write(buffer, 0, length);
                    fstr.Close();
                    MessageBox.Show(@"File has been downloaded to c:\downFile\! ",
        "RHDB - about Attachment", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

posted @ 2011-06-29 10:12  Kong, Star  阅读(572)  评论(0编辑  收藏  举报