把byte[]里挨个取出来往里写就行了啊
你的问题是什么?

解决方案 »

  1.   

    不再是我的byte数组一样的原数据,如0x34,就变成了4了,和我想的不一样
      

  2.   

                byte[] buf=new byte[200];
                .........
                StreamWriter sw = new StreamWriter("C;\\1.txt");
                sw.Write(buf);
                sw.Close();
                sw.Dispose();
      

  3.   

    参见http://msdn.microsoft.com/zh-cn/library/2bbab5dh(VS.80).aspx
      

  4.   

                FileStream fs = new FileStream("C:\\1.txt",FileMode.OpenOrCreate,FileAccess.Write);
                fs.Write(buf, 0, buf.Length);
                fs.Close();
                fs.Dispose();
      

  5.   

    byte[] byData;  
    FileStream fs= new FileStream("a.txt", FileMode.Create);       
    fs.Seek(0, SeekOrigin.Begin); 
    fs.Write(byData, 0, byData.Length);                                System.IO.File.WriteAllBytes("", byData); 
      

  6.   

                byte[] a = new byte[160];
                StringBuilder s = new StringBuilder();
                Random r = new Random(DateTime.Now.Millisecond);
                for (int i = 0; i < 160; i++)
                {
                    a[i] = (byte)r.Next(256);
                    s.Append(((i % 16==0 && i>0)?"\r\n":"") + "0x" + a[i].ToString("x") + " ");
                }
                StreamWriter sw = new StreamWriter("C:\\1.txt");
                sw.Write(s.ToString());
                sw.Close();
                sw.Dispose();
      

  7.   


    肯定要变成字符,你怎么样的?你定义都成byte[]{0x34,0x45,0x58.......0x57}了,写入文件按照asc吗对照着写入了要写入字符串,定义string[]=new string[]{"0x34","0x45","0x58"......."0x57"};            string[] str = new string[] { "0x34", "0x45", "0x58", "0x57" };
                StreamWriter sw = new StreamWriter("C:\\1.txt");
                foreach (string s in str)
                    sw.WriteLine(s);
                sw.Close();
                sw.Dispose();
      

  8.   


    我的数据时从MCU读出来的byte[]数组,我想把这些数组保存到文本文件中,这样我就可以检查别人给我的数据有没有错误,
    不过我还是要谢谢你,